:root {
  --ink: #282333;
  --muted: #746e7e;
  --paper: #fbf8f3;
  --card: #ffffff;
  --line: #e8e1dc;
  --primary: #7058a3;
  --primary-dark: #57417f;
  --sleep: #6d75b8;
  --awake: #edbd59;
  --feeding: #58a68e;
  --crying: #dc725f;
  --shadow: 0 12px 36px rgba(56, 42, 76, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 10% 0%, #f1eafa 0, transparent 27rem), var(--paper); color: var(--ink); font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--primary-dark); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar { height: 70px; max-width: 1180px; margin: auto; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; gap: 10px; align-items: center; color: var(--ink); font-size: 1.08rem; font-weight: 760; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: white; font-size: 1.2rem; }
.link-button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 8px; }
.page { max-width: 1120px; margin: 0 auto; padding: 28px 24px 110px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.8rem, 4vw, 2.55rem); letter-spacing: -.045em; line-height: 1.1; }
h2 { margin-bottom: 8px; font-size: 1.25rem; letter-spacing: -.025em; }
.eyebrow { margin-bottom: 7px; color: var(--primary); font-weight: 760; font-size: .74rem; letter-spacing: .13em; text-transform: uppercase; }
.muted { color: var(--muted); line-height: 1.55; }
.hidden { display: none !important; }
.card { background: rgba(255,255,255,.92); border: 1px solid rgba(232,225,220,.85); border-radius: 22px; box-shadow: var(--shadow); padding: 24px; }
.narrow { max-width: 480px; margin: 6vh auto; }
.auth-card h1 { font-size: 2.15rem; }

.button { display: inline-flex; min-height: 44px; padding: 10px 17px; border: 0; border-radius: 13px; align-items: center; justify-content: center; font-weight: 720; cursor: pointer; }
.button.primary { background: var(--primary); color: white; box-shadow: 0 6px 16px rgba(112,88,163,.2); }
.button.primary:hover { background: var(--primary-dark); }
.button.subtle { background: #f0eaf6; color: var(--primary-dark); }
.button.danger { background: #fff0ed; color: #a33c2e; }
.button.wide { width: 100%; margin-top: 8px; }
.button:disabled { opacity: .55; cursor: wait; }
.button-row, .form-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.stacked-form { display: grid; gap: 15px; margin-top: 24px; }
.field { display: grid; gap: 7px; }
.field > label, .stacked-form > label, .invite-box label { color: #4f4858; font-size: .88rem; font-weight: 700; }
.field input, .field select, .field textarea, .stacked-form > input, .invite-box input, .custom-dates input { width: 100%; border: 1px solid #dcd4df; border-radius: 12px; background: white; color: var(--ink); padding: 11px 12px; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus, .stacked-form > input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(112,88,163,.12); }
.field small { color: var(--muted); font-size: .76rem; line-height: 1.35; }
.field small ul { margin: 4px 0 0; padding-left: 19px; }
.field-error, .form-errors { color: #a33c2e; background: #fff0ed; border-radius: 10px; padding: 9px 11px; font-size: .86rem; }
.form-errors ul { margin: 0; padding-left: 18px; }
.form-card { max-width: 700px; }
.form-card hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.audit-note { margin: 18px 0 0; color: var(--muted); font-size: .8rem; }

.messages { position: fixed; z-index: 30; top: 75px; left: 50%; transform: translateX(-50%); width: min(92vw, 560px); }
.message { padding: 13px 16px; background: #edf8f4; color: #286a55; border: 1px solid #bfe1d5; border-radius: 13px; box-shadow: var(--shadow); }
.message.error { background: #fff0ed; border-color: #f2c5bd; color: #943629; }
.message.warning { background: #fff7e5; border-color: #edd8a7; color: #825c15; }
.toast { position: fixed; z-index: 50; bottom: 95px; left: 50%; translate: -50% 20px; padding: 12px 17px; background: var(--ink); color: white; border-radius: 12px; opacity: 0; pointer-events: none; transition: .2s; }
.toast.visible { opacity: 1; translate: -50% 0; }
.toast.error { background: #963f31; }

.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 15px 0 28px; }
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.quick-card { position: relative; min-height: 156px; padding: 18px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; border-radius: 20px; border: 1px solid var(--line); background: white; box-shadow: 0 6px 24px rgba(56,42,76,.055); }
.quick-card::after { content: ''; position: absolute; width: 90px; height: 90px; border-radius: 50%; right: -35px; top: -35px; background: currentColor; opacity: .1; }
.quick-card.type-sleep { color: var(--sleep); }.quick-card.type-awake { color: #b17b0a; }.quick-card.type-feeding { color: var(--feeding); }.quick-card.type-crying { color: var(--crying); }
.quick-card.running { border-color: currentColor; box-shadow: 0 8px 26px color-mix(in srgb, currentColor 18%, transparent); }
.activity-icon { font-size: 1.7rem; }
.quick-copy { display: flex; flex-direction: column; gap: 3px; color: var(--ink); }
.quick-copy strong { font-size: 1.05rem; }.quick-copy span { color: var(--muted); font-size: .79rem; }
.quick-copy .adjust-link { position: relative; z-index: 2; width: max-content; color: currentColor; font-size: .7rem; font-weight: 720; text-decoration: underline; text-underline-offset: 2px; }
.quick-card form { position: absolute; right: 15px; bottom: 15px; }
.round-action { width: 43px; height: 43px; padding: 0; border: 0; border-radius: 50%; background: currentColor; color: white; cursor: pointer; box-shadow: 0 5px 14px rgba(0,0,0,.12); }
.round-action.stop { background: var(--ink); }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 42px 0 14px; }
.section-heading h1, .section-heading h2, .section-heading p { margin-bottom: 0; }
.section-heading > a:not(.button) { padding-bottom: 3px; font-weight: 700; font-size: .88rem; }
.page-title { margin-top: 10px; }
.event-list { border: 1px solid var(--line); background: white; border-radius: 18px; overflow: hidden; }
.event-row { min-height: 70px; padding: 12px 16px; display: flex; align-items: center; gap: 13px; color: var(--ink); border-bottom: 1px solid #eee8e4; }
.event-row:last-child { border-bottom: 0; }.event-row:hover { background: #fdfbf8; }
.event-dot { width: 11px; height: 36px; flex: 0 0 auto; border-radius: 8px; }
.event-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.event-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.event-duration { color: var(--muted); font-weight: 650; font-size: .85rem; text-align: right; }
.event-duration.live { color: var(--primary); }
.empty-state { min-height: 180px; padding: 35px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); }
.empty-state span { font-size: 1.6rem; color: var(--primary); }.empty-state strong { color: var(--ink); margin: 7px 0; }.empty-state p { margin: 0; }

.bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: 17px; translate: -50%; display: flex; gap: 2px; padding: 6px; background: rgba(43,38,51,.94); backdrop-filter: blur(12px); border-radius: 20px; box-shadow: 0 15px 40px rgba(0,0,0,.2); }
.bottom-nav a { min-width: 84px; padding: 8px 12px; display: flex; flex-direction: column; align-items: center; gap: 3px; border-radius: 14px; color: #c9c2d1; font-size: .68rem; font-weight: 650; }
.bottom-nav a span { font-size: 1.08rem; }.bottom-nav a.active { color: white; background: rgba(255,255,255,.13); }

.week-nav { max-width: 420px; margin: 0 auto 17px; display: flex; align-items: center; justify-content: space-between; }
.week-nav a { padding: 7px 12px; border-radius: 10px; font-weight: 700; }.week-nav a:hover { background: #ede6f3; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; margin-bottom: 13px; color: var(--muted); font-size: .78rem; }
.legend span { display: flex; align-items: center; gap: 5px; }.legend i { width: 10px; height: 10px; border-radius: 50%; }
.calendar-card { padding: 17px 14px; overflow-x: auto; }
.time-axis { min-width: 680px; padding-left: 73px; display: flex; justify-content: space-between; color: var(--muted); font-size: .67rem; }
.day-row { min-width: 680px; display: grid; grid-template-columns: 63px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid #eee9e5; }
.day-row:last-child { border-bottom: 0; }.day-row.today .day-label strong { color: var(--primary); }
.day-label { display: flex; flex-direction: column; justify-content: center; }.day-label strong { text-transform: uppercase; font-size: .77rem; }.day-label span { color: var(--muted); font-size: .69rem; }
.timeline { position: relative; height: 58px; overflow: hidden; border-radius: 9px; background: #f6f2ee; }
.grid-line { position: absolute; top: 0; bottom: 0; border-left: 1px dashed #d9d1cb; }.line-6 { left: 25%; }.line-12 { left: 50%; }.line-18 { left: 75%; }
.segment { position: absolute; min-width: 2px; border-radius: 5px; opacity: .93; transition: filter .15s, transform .15s; }.segment:hover { filter: brightness(.9); transform: scaleY(1.12); z-index: 3; }
.segment.type-sleep, .segment.type-awake { height: 24px; top: 6px; }
.segment.type-crying { height: 12px; bottom: 7px; z-index: 1; }
.segment.type-feeding { height: 12px; bottom: 7px; z-index: 2; box-shadow: 0 0 0 2px rgba(255,255,255,.65); }
.type-sleep { background-color: var(--sleep); }.type-awake { background-color: var(--awake); }.type-feeding { background-color: var(--feeding); }.type-crying { background-color: var(--crying); }
.cry-summary { margin-top: 4px; color: var(--muted); font-size: .67rem; }.cry-summary strong { color: var(--crying); }
.calendar-help { margin: 14px 6px; font-size: .8rem; text-align: center; }

.period-picker { margin: 22px 0 18px; padding: 10px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.segmented button { padding: 10px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }.segmented button.active { background: #ece5f4; color: var(--primary-dark); }
.custom-dates { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 15px 5px 2px; }.custom-dates label { color: var(--muted); font-size: .78rem; }.custom-dates input { display: block; margin-top: 4px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-card { min-height: 105px; padding: 18px; display: flex; flex-direction: column; justify-content: space-between; border-radius: 17px; background: var(--ink); color: white; }.stat-card:nth-child(2) { background: var(--crying); }.stat-card:nth-child(3) { background: var(--primary); }.stat-card:nth-child(4) { background: var(--feeding); }
.stat-card span { opacity: .75; font-size: .75rem; }.stat-card strong { font-size: 1.35rem; }
.insight-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 15px; margin-top: 15px; }.chart-card { min-height: 340px; }
.bar-chart { margin-top: 22px; display: grid; gap: 9px; }.bar-chart.hourly { max-height: 260px; overflow-y: auto; padding-right: 6px; }
.bar-row { display: grid; grid-template-columns: 42px 1fr 25px; gap: 9px; align-items: center; font-size: .71rem; color: var(--muted); }.bar-row i { height: 8px; background: #f0ebe8; border-radius: 8px; overflow: hidden; }.bar-row b { display: block; height: 100%; border-radius: 8px; background: var(--crying); }.bar-row strong { text-align: right; color: var(--ink); }
.context-card { margin-top: 15px; }.context-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0; }.context-grid div { padding: 17px; border-radius: 15px; background: #f5f0f8; }.context-grid span { display: block; margin-bottom: 8px; color: var(--muted); font-size: .78rem; }.context-grid strong { font-size: 1.18rem; }.context-card > .muted { margin-bottom: 0; font-size: .78rem; }

.settings-grid { display: grid; grid-template-columns: 1fr 1.6fr; gap: 15px; }.settings-grid .card:nth-child(n+3) { grid-column: span 1; }
.member-list { list-style: none; margin: 18px 0; padding: 0; display: grid; gap: 10px; }.member-list li { display: flex; align-items: center; gap: 10px; }.member-list li div { display: flex; flex-direction: column; }.member-list small { color: var(--muted); }.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #ece5f4; color: var(--primary); font-weight: 750; }
.invite-box { margin-top: 16px; }.invite-box > div { display: flex; gap: 7px; margin-top: 7px; }.invite-box input { min-width: 0; font-size: .75rem; }
.history-list { padding: 4px 20px; }.history-list article { display: grid; grid-template-columns: 140px 1fr; padding: 16px 0; border-bottom: 1px solid var(--line); }.history-list article:last-child { border-bottom: 0; }.history-list article > div { display: flex; flex-direction: column; }.history-list small { color: var(--muted); }.history-action { color: var(--primary); font-size: .8rem; font-weight: 730; }

@media (max-width: 760px) {
  .topbar { height: 58px; padding: 0 17px; }.page { padding: 18px 14px 100px; }.brand { font-size: .96rem; }.brand-mark { width: 30px; height: 30px; }
  .hero { align-items: flex-start; flex-direction: column; margin-top: 8px; }.hero .button { align-self: stretch; }
  .quick-grid { grid-template-columns: 1fr 1fr; }.quick-card { min-height: 145px; }
  .section-heading { margin-top: 34px; }.page-title { align-items: flex-start; margin-top: 5px; }
  .bottom-nav { width: calc(100% - 18px); bottom: max(8px, env(safe-area-inset-bottom)); justify-content: space-around; }.bottom-nav a { min-width: 0; flex: 1; padding-inline: 3px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }.insight-grid, .settings-grid { grid-template-columns: 1fr; }.settings-grid .card:nth-child(n+3) { grid-column: auto; }
  .event-row { gap: 9px; padding-inline: 12px; }.event-main small { font-size: .72rem; }.event-duration { max-width: 95px; font-size: .73rem; }
  .context-grid { grid-template-columns: 1fr; }.auth-card { margin-top: 2vh; }.card { padding: 19px; }
}

@media (max-width: 390px) {
  .quick-card { min-height: 136px; padding: 14px; }.round-action { width: 39px; height: 39px; }
  .section-heading { gap: 10px; }.section-heading .button { padding-inline: 11px; font-size: .8rem; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
