:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
  color-scheme: light;
  --ink: #3E5B73;
  --ink-soft: #566F83;
  --blue: #D9E9F6;
  --blue-hover: #C8DFF0;
  --blue-border: #8CAEC8;
  --sage: #DDEBDD;
  --sage-ink: #355B40;
  --peach: #F9E2D7;
  --lavender: #E9E2F4;
  --lavender-ink: #66547F;
  --green: var(--ink);
  --green-soft: var(--sage);
  --cream: #F6FAFD;
  --paper: #FFFFFF;
  --coral: #466C89;
  --gold: var(--peach);
  --line: rgba(62, 91, 115, .16);
}

button:disabled { opacity: .58; cursor: default; }
.connection { display:flex; align-items:center; padding:12px 15px; margin-bottom:14px; border:1px solid var(--line); border-radius:14px; background:var(--peach); font-size:12px; }
.connection.connected { background:var(--green-soft); }
.connected .live-dot { background:#558064; }
.position-card, .invite-card { margin-top:16px; padding:20px; border:1px solid var(--line); border-radius:22px; background:var(--paper); }
.position-card h2, .invite-card h2 { margin:0; font-family:Georgia,serif; font-size:22px; }
.position-card p, .invite-card p { font-size:13px; color:var(--ink-soft); line-height:1.6; }
.position-card .coordinates { font-size:21px; color:var(--green); font-variant-numeric:tabular-nums; }
.map-link { display:block; font-size:13px; }
.fine-print { font-size:12px; line-height:1.7; color:var(--ink-soft); margin-top:18px; }
.error { background:#FFF0E9; border:1px solid #DFC0AD; padding:12px 16px; border-radius:13px; font-size:13px; line-height:1.6; }
.settings-card textarea { display:block; width:100%; min-height:96px; margin-top:8px; padding:12px; border-radius:12px; border:1px solid var(--line); font:inherit; color:var(--green); background:var(--paper); resize:vertical; }
.settings-card p { margin:0; font-size:14px; line-height:1.6; }
.settings-card small { line-height:1.6; color:var(--ink-soft); }
.invite-card input { width:100%; margin:0 0 12px; padding:12px; border:1px solid var(--line); border-radius:10px; color:var(--ink-soft); background:var(--cream); font-size:12px; }
.invite-card button { width:100%; }
.invite-qr { display:block; width:276px; max-width:100%; height:auto; margin:15px auto; border-radius:8px; image-rendering:pixelated; }
.message-status { max-width:70px; text-align:right; line-height:1.5; }
.section-title { gap:12px; }
textarea:focus-visible { outline:3px solid var(--blue-border); outline-offset:2px; }

* { box-sizing: border-box; }
html { scroll-padding-top: calc(92px + env(safe-area-inset-top, 0px)); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--cream); }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--blue-border); outline-offset: 2px; }

#app { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); }
.topbar { position: sticky; top: 0; z-index: 30; min-height: calc(76px + env(safe-area-inset-top, 0px)); padding: calc(12px + env(safe-area-inset-top, 0px)) max(20px, calc((100% - 720px) / 2)) 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; background: var(--blue); border-bottom: 1px solid var(--line); box-shadow: 0 3px 12px rgba(62, 91, 115, .05); }
.brand { display: flex; gap: 9px; align-items: center; font-family: Georgia, serif; font-size: 21px; font-weight: 700; }
.brand-mark { width: 52px; height: 52px; object-fit: contain; }
.brand { gap: 8px; font-weight: 500; font-size: 24px; letter-spacing: -.04em; }
.brand small { display: block; margin-top: 3px; font-family: Georgia, "Palatino Linotype", Palatino, serif; font-size: 12px; font-style: italic; font-weight: 400; letter-spacing: .015em; color: var(--ink-soft); }
.hero { position: relative; isolation: isolate; }
.hero-doudou { float: right; width: 132px; height: 132px; margin: 2px 0 10px 16px; }
.hero::after { content: ""; display: block; clear: both; }
.avatar { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.72); font-weight: 750; cursor: pointer; }
main { width: min(720px, 100%); margin: 0 auto; padding: 0 18px 40px; }

.hero { padding: 35px 4px 25px; }
.eyebrow { margin: 0 0 10px; text-transform: uppercase; letter-spacing: .17em; font-size: 11px; font-weight: 800; color: var(--coral); }
h1 { margin: 0; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(37px, 10vw, 57px); line-height: .98; letter-spacing: -.035em; }
h1 em { color: var(--coral); font-weight: 400; }
.intro, .page-heading > p:last-child { color: var(--ink-soft); font-size: 15px; line-height: 1.6; max-width: 520px; }

.status-card { overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 25px; box-shadow: 0 15px 40px rgba(62, 91, 115, .05); }
.status-card.active { border-color: rgba(42, 132, 94, .33); }
.status-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.status-label { font-size: 13px; font-weight: 800; }
.live-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: #aab7b2; }
.active .live-dot { background: #2a845e; box-shadow: 0 0 0 5px rgba(42,132,94,.12); }
.privacy-pill { border-radius: 99px; padding: 5px 10px; background: var(--green-soft); font-size: 11px; font-weight: 750; }
.status-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 20px 18px; }
.muted { display: block; margin-bottom: 6px; color: var(--ink-soft); font-size: 11px; }
.countdown { font-family: Georgia, serif; font-size: 27px; }
.tracking-toggle { border: 0; border-radius: 12px; padding: 11px 14px; background: var(--blue); color: var(--ink); font-size: 12px; font-weight: 750; cursor: pointer; }
.location-note { margin: 0; padding: 0 18px 16px; color: var(--ink-soft); font-size: 11px; }

.presence-button { width: 100%; margin: 14px 0 28px; padding: 16px; display: flex; align-items: center; gap: 14px; text-align: left; border: 0; border-radius: 19px; background: var(--blue); color: var(--ink); box-shadow: 0 12px 25px rgba(62, 91, 115, .12); cursor: pointer; }
.presence-button:disabled { background: var(--blue); color: var(--ink-soft); cursor: default; box-shadow: none; }
.presence-button:disabled small { opacity: 1; }
.presence-icon { display: grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.18); font-size: 23px; }
.presence-button strong, .presence-button small { display: block; }
.presence-button strong { font-size: 16px; }
.presence-button small { margin-top: 3px; opacity: .78; }

.section { margin-top: 28px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 13px; }
.section-title h2 { margin: 0; font-family: Georgia, serif; font-size: 20px; }
.section-title button { border: 0; background: transparent; color: var(--coral); font-size: 12px; font-weight: 750; cursor: pointer; }
.quick-grid, .signal-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick-button { min-height: 92px; padding: 11px 7px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.68); cursor: pointer; }
.quick-button > span { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--green-soft); font-size: 17px; font-weight: 800; }
.quick-button small { font-size: 12px; font-weight: 600; line-height: 1.4; max-width: 145px; }
.quick-button { min-height: 132px; padding: 10px 8px 14px; gap: 6px; transition: background .18s ease, border-color .18s ease; }
.quick-button:hover { border-color: var(--blue-border); background: var(--paper); }
.quick-button:active { background: var(--blue); }
.quick-button > span { width: 76px; height: 76px; background: transparent; }
.quick-button .doudou-icon { width: 100%; height: 100%; }
.doudou-icon { display: block; object-fit: contain; }
.signal-grid .quick-button { min-height: 154px; }
.signal-grid .quick-button > span { width: 88px; height: 88px; }
.message-icon { flex: 0 0 48px; height: 48px; background: transparent; }
.message-icon .doudou-icon { width: 48px; height: 48px; }
.presence-icon { width: 56px; height: 56px; background: var(--peach); }
.presence-icon .doudou-icon { width: 54px; height: 54px; }
.quick-button.priority { background: #fff0e9; border-color: rgba(217,117,80,.3); }
.quick-button.priority > span { background: transparent; }

.message-list { background: rgba(255,255,255,.52); border: 1px solid var(--line); border-radius: 19px; overflow: hidden; }
.message-list article { display: flex; align-items: center; gap: 12px; min-height: 67px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.message-list article:last-child { border-bottom: 0; }
.message-icon { display: grid; place-items: center; border-radius: 50%; }
.message-list article div { min-width: 0; flex: 1; }
.message-list strong, .message-list small { display: block; }
.message-list strong { font-size: 13px; }
.message-list small { margin-top: 4px; overflow: hidden; color: var(--ink-soft); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.message-status { color: var(--ink-soft); font-size: 10px; }
.empty-list { padding: 25px; border: 1px dashed rgba(23,63,56,.2); border-radius: 17px; color: var(--ink-soft); text-align: center; font-size: 13px; }

.page-heading { padding: 33px 4px 24px; }
.page-heading h1 { font-size: 43px; }
.map-shell { position: relative; height: min(58vh, 510px); overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: #e5e7df; box-shadow: 0 15px 40px rgba(29,55,48,.08); }
#map { height: 100%; }
.map-empty { position: absolute; z-index: 500; top: 50%; left: 50%; width: 220px; transform: translate(-50%, -50%); padding: 20px; border-radius: 18px; background: rgba(255,255,255,.96); text-align: center; box-shadow: 0 10px 30px rgba(23,63,56,.12); }
.map-empty span, .map-empty strong { display: block; }
.map-empty span { margin-bottom: 8px; font-size: 27px; color: var(--coral); }
.map-empty p { margin: 6px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.4; }
.map-actions { display: grid; gap: 10px; margin-top: 15px; }
.primary, .secondary { min-height: 48px; padding: 13px 18px; border: 0; border-radius: 14px; text-align: center; font-weight: 750; text-decoration: none; cursor: pointer; }
.primary { background: var(--blue); color: var(--ink); }
.primary:hover:not(:disabled), .tracking-toggle:hover:not(:disabled) { background: var(--blue-hover); }
.secondary:hover:not(:disabled) { background: var(--blue); }
.secondary { background: var(--paper); border: 1px solid var(--line); color: inherit; }

.signal-grid { grid-template-columns: repeat(2, 1fr); }
.signal-grid .quick-button { min-height: 154px; }
.settings-card, .info-card, .settings-list { padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.65); }
.settings-card { display: grid; gap: 16px; }
.settings-card label { font-size: 12px; font-weight: 800; }
.settings-card input { width: 100%; margin-top: 7px; padding: 13px 14px; border: 1px solid rgba(23,63,56,.18); border-radius: 12px; background: var(--paper); color: var(--green); }
.info-card { display: flex; gap: 13px; margin-top: 14px; }
.info-icon { display: grid; place-items: center; flex: 0 0 auto; width: 29px; height: 29px; border-radius: 50%; background: var(--gold); font-family: Georgia, serif; font-weight: 800; }
.info-card p { margin: 5px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.settings-list { margin-top: 14px; padding: 0 16px; }
.settings-list button { width: 100%; padding: 17px 0; display: flex; justify-content: space-between; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.settings-list button:last-child { border-bottom: 0; }

.bottom-nav { position: fixed; z-index: 1000; left: 50%; right: auto; bottom: calc(14px + env(safe-area-inset-bottom, 0px) + var(--visible-bottom-gap, 0px)); transform: translateX(-50%); width: calc(100% - 28px); max-width: 470px; height: 68px; padding: 8px; display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 8px 30px rgba(23,63,56,.10); backdrop-filter: blur(18px); }
.bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: transparent; color: var(--ink-soft); cursor: pointer; }
.bottom-nav button span { font-size: 20px; line-height: 1; }
.bottom-nav button small { font-size: 9px; font-weight: 700; }
.bottom-nav button.selected { color: var(--coral); }
.bottom-nav button { min-height: 44px; justify-content: center; }
.bottom-nav button span { padding: 4px 14px; border-radius: 14px; }
.bottom-nav button.selected span { background: var(--blue); }
.nav-icon { display: block; width: 23px; height: 23px; }
.bottom-nav button small { font-size: 10px; }
.toast { position: fixed; z-index: 2000; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); left: 18px; max-width: 510px; margin: 0 auto; padding: 13px 16px; border-radius: 14px; background: var(--blue); color: var(--ink); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; box-shadow: 0 12px 30px rgba(23,63,56,.25); font-size: 12px; text-align: center; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (min-width: 700px) {
  main { padding-inline: 30px; }
  .bottom-nav { max-width: 470px; }
  #app { padding-bottom: 105px; }
  .toast { bottom: 100px; }
}

@media (max-width: 520px) {
  .hero-doudou { width: 88px; height: 88px; margin: 0 0 0 6px; }
  .hero h1 { font-size: 37px; }
  .hero .intro { clear: both; padding-top: 12px; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 380px) {
  .hero h1 { font-size: 32px; }
  .hero-doudou { width: 76px; height: 76px; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .status-body { align-items: stretch; flex-direction: column; }
}

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