:root {
  --bg: #d6f2e6;
  --card: #ffffff;
  --ink: #213a31;
  --muted: #7e948a;
  --line: #e9f2ec;
  --brand: #2ec08a;
  --brand-ink: #1e9c6d;
  --green: #2ec08a;
  --amber: #f0a52b;
  --accent: #ff7a42;
  --red: #ef5a6a;
  --shadow: 0 12px 30px rgba(28, 85, 61, 0.12);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
}

/* ---------- phone app shell (parent.html / child.html) ---------- */
body.app-page {
  background: radial-gradient(900px 500px at 50% -10%, #bfead7, var(--bg));
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.app {
  position: relative;
  width: 100%; max-width: 412px;
  height: 100%; max-height: 860px; min-height: 560px;
  background: #f5fbf8;
  border-radius: 38px;
  box-shadow: 0 26px 60px rgba(28, 85, 61, .20);
  overflow: hidden;
  display: flex; flex-direction: column;
}
/* when embedded in the showcase iframe, drop the frame */
body.embed { background: #f4f6fc; padding: 0; }
body.embed .app {
  max-width: none; max-height: none; height: 100%;
  border-radius: 0; box-shadow: none;
}

/* status bar */
.statusbar {
  height: 40px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; font-size: 13px; font-weight: 700; color: var(--ink);
  background: #fff;
}
.statusbar .right { display: flex; align-items: center; gap: 6px; }
.statusbar .right svg { width: 16px; height: 16px; }

/* app bar */
.appbar {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px 12px; background: #fff; border-bottom: 1px solid var(--line);
}
.logo {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  background: linear-gradient(145deg, #45d49f, #23ac7b);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 6px 14px rgba(79, 110, 247, 0.4);
}
.logo svg { width: 20px; height: 20px; }
.appbar h1 { font-size: 16px; margin: 0; letter-spacing: -0.2px; }
.appbar .sub { margin: 1px 0 0; font-size: 11.5px; color: var(--muted); }
.spacer { flex: 1; }
.pill {
  font-size: 11.5px; font-weight: 700; padding: 6px 11px; border-radius: 999px;
  background: #f2f5fd; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c3cbe0; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(34,176,125,.18); }
.dot.off { background: #c3cbe0; }

/* body + tab panels */
.body { position: relative; flex: 1; overflow: hidden; }
.panel { position: absolute; inset: 0; display: none; }
.panel.active { display: block; }
.panel.scroll { overflow-y: auto; padding: 16px; }

/* map tab */
#map { position: absolute; inset: 0; }
.sheet {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  background: #fff; border-radius: 22px; box-shadow: var(--shadow);
  padding: 14px; z-index: 500;
}
.kid { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 46px; height: 46px; border-radius: 15px; flex: none;
  background: linear-gradient(145deg, #ffd98a, #ffb24d);
  display: grid; place-items: center; color: #7a4a00; font-weight: 800; font-size: 19px;
}
.kid .name { font-weight: 800; font-size: 16px; }
.kid .meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.kid .batt-mini { text-align: right; }
.kid .batt-mini .v { font-weight: 800; font-size: 16px; }
.kid .batt-mini .k { font-size: 11px; color: var(--muted); }
.sheet .acts { display: flex; gap: 9px; margin-top: 12px; }

/* floating locate btn */
.fab {
  position: absolute; right: 14px; z-index: 500;
  width: 46px; height: 46px; border-radius: 15px; border: none; cursor: pointer;
  background: #fff; box-shadow: var(--shadow); color: var(--brand);
  display: grid; place-items: center;
}
.fab svg { width: 22px; height: 22px; }
.fab.locate { bottom: 108px; }

/* buttons */
.btn {
  border: none; cursor: pointer; font-family: inherit; font-weight: 700;
  border-radius: 13px; padding: 12px 15px; font-size: 14px;
  background: var(--brand); color: #fff; transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: #eef1fb; color: var(--brand-ink); }
.btn.block { width: 100%; }
.row { display: flex; gap: 9px; }

/* cards inside scroll tabs */
.block-card { background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 15px; margin-bottom: 14px; }
.block-card h2 { font-size: 12px; margin: 0 0 12px; color: var(--muted); font-weight: 800;
  text-transform: uppercase; letter-spacing: .6px; }

/* sos banner */
.sos-banner {
  position: absolute; left: 12px; right: 12px; top: 12px; z-index: 600;
  display: none; align-items: center; gap: 11px;
  background: linear-gradient(135deg, #ff5a6a, #e8384b); color: #fff;
  border-radius: 18px; padding: 13px 14px;
  box-shadow: 0 12px 26px rgba(239, 75, 92, .45);
  animation: pulse 1.4s infinite;
}
.sos-banner.show { display: flex; }
@keyframes pulse { 0%,100% { box-shadow: 0 12px 26px rgba(239,75,92,.45);} 50% { box-shadow: 0 12px 40px rgba(239,75,92,.8);} }
.sos-banner .big { font-weight: 800; font-size: 14.5px; }
.sos-banner .small { font-size: 11.5px; opacity: .92; margin-top: 1px; }
.sos-banner button { flex: none; }

/* zones + events */
.zrow { display:flex; align-items:center; gap:10px; padding:10px 12px; background:#f6f8ff;
  border:1px solid var(--line); border-radius:13px; margin-bottom: 8px; }
.events { display: flex; flex-direction: column; gap: 4px; }
.ev { display: flex; gap: 11px; align-items: flex-start; padding: 9px 2px; }
.ev .ic { width: 32px; height: 32px; border-radius: 11px; flex: none; display: grid; place-items: center; }
.ev .ic svg { width: 16px; height: 16px; }
.ev.enter .ic { background: #e3f6ee; color: var(--green); }
.ev.exit  .ic { background: #fdf0dd; color: var(--amber); }
.ev.sos   .ic { background: #fde3e6; color: var(--red); }
.ev.battery .ic { background: #fdf0dd; color: var(--amber); }
.ev.info  .ic { background: #eef1fb; color: var(--brand); }
.ev .t { font-size: 14px; font-weight: 600; }
.ev .ago { font-size: 12px; color: var(--muted); margin-top: 1px; }
.empty { color: var(--muted); font-size: 13.5px; text-align: center; padding: 18px 0; }

/* bottom tab bar */
.tabbar {
  flex: none; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
}
.tabbar button {
  flex: 1; border: none; background: none; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; color: var(--muted); font-size: 11px; font-weight: 700;
}
.tabbar button svg { width: 23px; height: 23px; }
.tabbar button.on { color: var(--brand); }
.tabbar .badge { position: relative; }
.tabbar .badge.alert::after {
  content: ""; position: absolute; top: -2px; right: -5px; width: 9px; height: 9px;
  background: var(--red); border-radius: 50%; border: 2px solid #fff;
}

/* ---------- child screen ---------- */
.kidscreen { padding: 20px 18px; display: flex; flex-direction: column; height: 100%; }
.kidscreen .hint { text-align:center; color: var(--muted); font-size: 14px; margin: 6px 0 14px; }
.sos-btn {
  width: 186px; height: 186px; border-radius: 50%; border: none; cursor: pointer;
  margin: 8px auto; display: grid; place-items: center; flex: none;
  background: radial-gradient(circle at 50% 38%, #ff6472, #e8384b);
  color: #fff; font-weight: 900; font-size: 42px; letter-spacing: 2px;
  box-shadow: 0 16px 36px rgba(232,56,75,.5), inset 0 -6px 14px rgba(0,0,0,.15);
  transition: transform .1s;
}
.sos-btn:active { transform: scale(.95); }
.sos-btn.active { animation: ring 1s infinite; }
@keyframes ring { 0%,100%{box-shadow:0 16px 36px rgba(232,56,75,.5)} 50%{box-shadow:0 16px 54px rgba(232,56,75,.9)} }
.kidscreen .status { text-align:center; font-size: 13px; color: var(--muted); min-height: 18px; }
.toggle { display:flex; align-items:center; justify-content:space-between; gap:10px;
  background:#fff; border:1px solid var(--line); border-radius:15px; padding:13px 14px; margin-top:11px; box-shadow: var(--shadow); }
.toggle b { font-size: 14px; }
.toggle small { color: var(--muted); font-size: 11.5px; }
.sw { width: 48px; height: 28px; border-radius: 999px; background:#cfd6ea; position:relative; cursor:pointer; flex:none; transition:.2s; }
.sw.on { background: var(--green); }
.sw i { position:absolute; top:3px; left:3px; width:22px; height:22px; border-radius:50%; background:#fff; transition:.2s; box-shadow:0 2px 5px rgba(0,0,0,.2); }
.sw.on i { left:23px; }

/* zone tooltip label on map */
.zone-lbl { background: rgba(255,255,255,.9); border: none; box-shadow: 0 2px 6px rgba(0,0,0,.12);
  border-radius: 8px; font-weight: 700; font-size: 11px; color: #1b2440; padding: 2px 7px; }
.leaflet-tooltip-left.zone-lbl::before, .leaflet-tooltip-right.zone-lbl::before { display: none; }

/* ---------- showcase (index.html) ---------- */
body.show-page {
  background: radial-gradient(1100px 600px at 50% -10%, #bfead7, var(--bg));
  min-height: 100%;
}
.show-wrap { max-width: 1000px; margin: 0 auto; padding: 40px 18px 60px; text-align: center; }
.show-wrap .big-logo { width: 68px; height: 68px; border-radius: 21px; margin: 0 auto 16px;
  background: linear-gradient(145deg, #45d49f, #23ac7b); display: grid; place-items: center; color: #fff;
  box-shadow: 0 16px 36px rgba(79,110,247,.42); }
.show-wrap .big-logo svg { width: 38px; height: 38px; }
.show-wrap h1 { font-size: 27px; margin: 0 0 6px; }
.show-wrap .lead { color: var(--muted); margin: 0 0 34px; font-size: 15px; }
.phones { display: flex; gap: 40px; justify-content: center; align-items: flex-start; flex-wrap: wrap; }
.phone-demo { width: 300px; }
.phone-demo .label { font-weight: 800; font-size: 15px; margin-bottom: 12px; }
.phone-demo .label span { display:block; font-weight: 600; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.device {
  width: 300px; height: 620px; margin: 0 auto;
  background: #11162b; border-radius: 46px; padding: 11px;
  box-shadow: 0 30px 70px rgba(27, 36, 64, .3), inset 0 0 0 2px #2a3350;
  position: relative;
}
.device::before {
  content: ""; position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
  width: 108px; height: 24px; background: #11162b; border-radius: 0 0 16px 16px; z-index: 3;
}
.device iframe {
  width: 100%; height: 100%; border: none; border-radius: 36px; background: #f4f6fc; display: block;
}
.show-foot { color: var(--muted); font-size: 13px; margin-top: 34px; }
.show-foot a { color: var(--brand-ink); font-weight: 700; }
@media (max-width: 680px) { .phones { gap: 50px; } }

/* ---------- живий дракончик: анімується лише всередині .kt-live ---------- */
.kt-live svg.kt-dragon { animation: kt-breathe 2.6s ease-in-out infinite; transform-origin: 50% 90%; }
.kt-live .kt-wing { animation: kt-flap 1.1s ease-in-out infinite; transform-box: fill-box; transform-origin: 0% 60%; }
.kt-live .kt-tail { animation: kt-wag 2.2s ease-in-out infinite; transform-box: fill-box; transform-origin: 100% 20%; }
.kt-live .kt-eyes { animation: kt-blink 4.5s infinite; transform-box: fill-box; transform-origin: 50% 50%; }
@keyframes kt-breathe { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-5px) scale(1.025, .985); } }
@keyframes kt-flap { 0%,100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
@keyframes kt-wag { 0%,100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
@keyframes kt-blink { 0%,92%,100% { transform: scaleY(1); } 95% { transform: scaleY(.08); } }
@media (prefers-reduced-motion: reduce) { .kt-live svg.kt-dragon, .kt-live .kt-wing, .kt-live .kt-tail, .kt-live .kt-eyes { animation: none; } }
