/* Buku KIA — maternal & child health design tokens (teal + rose) */
:root {
  --bg: #fdf3f6;
  --bg-accent: #fce7ee;
  --surface: #ffffff;
  --surface-2: #fdeef3;
  --text: #3a1220;
  --text-muted: #8a5a68;
  --border: #f3d3de;
  --primary: #be185d;
  --primary-hover: #9d174d;
  --primary-soft: #fce7f3;
  --accent: #0f766e;
  --danger: #e11d48;
  --warn: #d97706;
  --nav-bg: rgba(255, 255, 255, 0.92);
  --shadow: 0 1px 2px rgb(58 18 32 / 0.06), 0 8px 24px rgb(190 24 93 / 0.08);
  --ring: rgb(190 24 93 / 0.35);
  --pattern: radial-gradient(ellipse 80% 50% at 50% -20%, rgb(244 114 182 / 0.22), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgb(20 184 166 / 0.10), transparent);
  color-scheme: light;
}

html.dark {
  --bg: #1f0a14;
  --bg-accent: #32101e;
  --surface: #29101c;
  --surface-2: #351523;
  --text: #f8e5ec;
  --text-muted: #c592a4;
  --border: #4a1c2d;
  --primary: #f472b6;
  --primary-hover: #fb7fc4;
  --primary-soft: #4a1c2d;
  --accent: #2dd4bf;
  --danger: #fb7185;
  --warn: #fbbf24;
  --nav-bg: rgba(31, 10, 20, 0.94);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.35), 0 8px 28px rgb(0 0 0 / 0.35);
  --ring: rgb(244 114 182 / 0.4);
  --pattern: radial-gradient(ellipse 80% 50% at 50% -20%, rgb(244 114 182 / 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgb(45 212 191 / 0.08), transparent);
  color-scheme: dark;
}

body {
  font-family: "Outfit", ui-sans-serif, system-ui, sans-serif;
  background-color: var(--bg);
  background-image: var(--pattern);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
}

.font-display {
  font-family: "Fraunces", Georgia, serif;
}

input, select, button, textarea {
  font: inherit;
}

.page-shell {
  margin-left: auto;
  margin-right: auto;
  display: flex;
  min-height: 100vh;
  max-width: 32rem;
  flex-direction: column;
  padding: 1rem 1rem 6rem;
}

@media (min-width: 640px) {
  .page-shell {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
}

.field {
  width: 100%;
  border-radius: 0.875rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.625rem 0.75rem;
  font-size: 1rem;
  min-height: 2.75rem;
  line-height: 1.25;
  transition: border-color 0.15s, box-shadow 0.15s;
}

select.field {
  appearance: auto;
  -webkit-appearance: menulist;
}

textarea.field {
  min-height: 5rem;
  resize: vertical;
}

/* Keep native date picker usable on mobile (do not set appearance:none). */
input[type="date"].field {
  display: block;
  min-height: 2.75rem;
  padding-inline-end: 0.5rem;
}

input[type="date"].field::-webkit-calendar-picker-indicator {
  opacity: 1;
  cursor: pointer;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0.15rem;
  margin-inline-start: 0.25rem;
}

.field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.field-readonly {
  background: var(--surface-2);
  color: var(--text-muted);
}

.password-field {
  position: relative;
}

.password-field .field {
  padding-right: 2.75rem;
}

.password-toggle {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.password-toggle:hover {
  color: var(--text);
  background: var(--surface-2);
}

.password-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.password-toggle svg {
  width: 1.125rem;
  height: 1.125rem;
}

.label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.btn-primary {
  display: block;
  width: 100%;
  border-radius: 0.875rem;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  text-align: center;
  transition: background 0.15s, transform 0.15s;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.985);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-ghost {
  display: block;
  width: 100%;
  border-radius: 0.875rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  text-align: center;
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-google {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  border-radius: 0.875rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.8rem 1rem;
  text-decoration: none;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 6%, transparent);
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.btn-google:hover {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--text) 22%, var(--border));
  box-shadow: 0 2px 8px color-mix(in srgb, var(--text) 8%, transparent);
}

.btn-google:active {
  transform: scale(0.985);
  box-shadow: none;
}

.btn-google:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.15rem 0 0.9rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.turnstile-wrap {
  display: flex;
  justify-content: center;
}

.link-muted {
  display: block;
  margin-top: 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.link-muted:hover {
  color: var(--primary);
}

.result-panel {
  margin-top: 1.25rem;
  border-radius: 1rem;
  background: var(--primary-soft);
  border: 1px solid var(--border);
  padding: 1rem;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border-radius: 0.875rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0.75rem 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.check-row:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.check-row input {
  margin-top: 0.15rem;
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.choice-pill {
  display: block;
  cursor: pointer;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  padding: 0.625rem 0.75rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.choice-pill:has(input:checked) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.menu-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.1rem 0.75rem;
  border-radius: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.2s, border-color 0.2s;
}

.menu-tile:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.menu-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 0.75rem;
  border-radius: 1rem;
}

.icon-pregnant { background: #fce7f3; color: #be185d; }
.icon-postpartum { background: #fef3c7; color: #b45309; }
.icon-child { background: #ccfbf1; color: #0f766e; }
.icon-anc { background: #e0e7ff; color: #4338ca; }
.icon-growth { background: #d1fae5; color: #059669; }
.icon-immun { background: #e0f2fe; color: #0369a1; }
.icon-book { background: #fce7f3; color: #be185d; }
.icon-prep { background: #fef3c7; color: #b45309; }

html.dark .icon-pregnant { background: #4a1c2d; color: #f472b6; }
html.dark .icon-postpartum { background: #78350f; color: #fcd34d; }
html.dark .icon-child { background: #134e4a; color: #2dd4bf; }
html.dark .icon-anc { background: #312e81; color: #a5b4fc; }
html.dark .icon-growth { background: #064e3b; color: #34d399; }
html.dark .icon-immun { background: #0c4a6e; color: #7dd3fc; }
html.dark .icon-book { background: #4a1c2d; color: #f472b6; }
html.dark .icon-prep { background: #78350f; color: #fcd34d; }

.choice-pill-active,
button.choice-pill.choice-pill-active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.7rem 1rem;
  font-weight: 600;
  text-decoration: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-muted {
  background: var(--surface-2);
  color: var(--text-muted);
}

.badge-success {
  background: rgba(20, 184, 166, 0.15);
  color: #0d9488;
}

.badge-danger {
  background: rgba(225, 29, 72, 0.12);
  color: #be123c;
}

.data-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.data-row:last-child {
  border-bottom: 0;
}

.data-row-label {
  color: var(--text-muted);
}

.quote-banner {
  border-radius: 1.25rem;
  background: linear-gradient(135deg, #be185d 0%, #ec4899 55%, #f472b6 100%);
  color: #fdf2f8;
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}

html.dark .quote-banner {
  background: linear-gradient(135deg, #4a1c2d 0%, #9d174d 50%, #be185d 100%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.page-header {
  display: grid;
  grid-template-columns: 2.75rem 1fr 2.75rem;
  align-items: center;
  gap: 0.5rem;
  margin: -0.25rem 0 1.25rem;
  padding: 0.15rem 0 0.75rem;
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(to bottom, var(--bg) 70%, transparent);
}

.page-header-title {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.back-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.menu-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  border-radius: 0.875rem;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.menu-list-item:hover {
  border-color: var(--primary);
  background: var(--surface-2);
}

.menu-list-item .chevron {
  color: var(--text-muted);
  flex-shrink: 0;
}

.success-banner {
  margin-bottom: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--primary-soft);
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  color: var(--text);
}

.error-banner {
  margin-bottom: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  color: var(--text);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.theme-toggle:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  border-top: 1px solid var(--border);
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
}

.pwa-install-banner {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 32rem;
  margin-left: auto;
  margin-right: auto;
  padding: 0.85rem 0.95rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  animation: fade-up 0.35s ease-out both;
}

body:not(:has(.bottom-nav)) .pwa-install-banner {
  bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
}

.pwa-install-text {
  flex: 1;
  min-width: 0;
}

.pwa-install-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

.pwa-install-body {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-muted);
}

.pwa-install-actions {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.pwa-install-btn {
  border-radius: 0.75rem;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.45rem 0.85rem;
  white-space: nowrap;
  transition: background 0.15s, transform 0.15s;
}

.pwa-install-btn:hover {
  background: var(--primary-hover);
}

.pwa-install-btn:active {
  transform: scale(0.98);
}

.pwa-install-dismiss {
  border-radius: 0.75rem;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2rem 0.35rem;
  white-space: nowrap;
}

.pwa-install-dismiss:hover {
  color: var(--text);
}

.nav-link {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  border-radius: 0.75rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
}

.nav-link.active {
  color: var(--primary);
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes soft-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.animate-fade-up {
  animation: fade-up 0.45s ease-out both;
}

.animate-fade-up-delay {
  animation: fade-up 0.5s ease-out 0.08s both;
}

.animate-soft-pulse {
  animation: soft-pulse 2.8s ease-in-out infinite;
}

/* Pemantauan mandiri calendar */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.cal-month-label {
  flex: 1;
  text-align: center;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.cal-jump {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 0;
}

.cal-jump-select {
  min-width: 0;
  max-width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: "Fraunces", Georgia, serif;
  font-size: 0.875rem;
  font-weight: 700;
  padding: 0.45rem 0.55rem;
}

.cal-jump-year {
  flex: 0 0 auto;
  width: 5.25rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cal-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  text-decoration: none;
}

.cal-nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.cal-nav-btn-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.25rem;
  margin-bottom: 0.35rem;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.25rem;
}

.cal-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.cal-day:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border);
}

.cal-day-num {
  line-height: 1;
}

.cal-day-out {
  opacity: 0.28;
}

.cal-day-disabled {
  cursor: default;
  color: var(--text-muted);
  opacity: 0.4;
}

.cal-day-today {
  border-color: var(--primary);
  background: var(--primary-soft);
  font-weight: 700;
}

.cal-day-hasdata {
  color: var(--accent);
}

.cal-day-dot {
  position: absolute;
  bottom: 0.3rem;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 9999px;
  background: var(--accent);
}

.cal-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgb(0 0 0 / 0.4);
}

.cal-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 50;
  width: min(100%, 32rem);
  max-height: min(85vh, 40rem);
  overflow-y: auto;
  transform: translateX(-50%);
  border-radius: 1.25rem 1.25rem 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 0.75rem 1.25rem 6.5rem;
}

.cal-sheet-handle {
  width: 2.5rem;
  height: 0.3rem;
  margin: 0 auto 0.75rem;
  border-radius: 9999px;
  background: var(--border);
}

.cal-sheet-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.cal-sheet-enter {
  transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}
.cal-sheet-enter-start {
  transform: translate(-50%, 100%);
  opacity: 0;
}
.cal-sheet-enter-end {
  transform: translate(-50%, 0);
  opacity: 1;
}
.cal-sheet-leave {
  transition: transform 0.15s ease-in, opacity 0.15s ease-in;
}
.cal-sheet-leave-start {
  transform: translate(-50%, 0);
  opacity: 1;
}
.cal-sheet-leave-end {
  transform: translate(-50%, 100%);
  opacity: 0;
}

.article-body {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.65;
}
.article-body > *:first-child {
  margin-top: 0;
}
.article-body > *:last-child {
  margin-bottom: 0;
}
.article-body p,
.article-body ul,
.article-body ol,
.article-body blockquote,
.article-body pre,
.article-body table {
  margin: 0.85em 0;
}
.article-body h2,
.article-body h3,
.article-body h4 {
  margin: 1.25em 0 0.5em;
  font-family: var(--font-display, inherit);
  font-weight: 700;
  color: var(--text);
}
.article-body h2 { font-size: 1.15rem; }
.article-body h3 { font-size: 1.05rem; }
.article-body a {
  color: var(--primary);
  text-decoration: underline;
}
.article-body ul,
.article-body ol {
  padding-left: 1.25rem;
}
.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: 0.75rem;
}
.article-body blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 0.85rem;
  color: var(--text-muted);
}
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .animate-fade-up,
  .animate-fade-up-delay,
  .animate-soft-pulse,
  .menu-tile,
  .pwa-install-banner {
    animation: none;
    transition: none;
  }
}
