:root {
  --bg: #f7f7f9;
  --panel: rgba(255,255,255,.76);
  --panel-strong: #fff;
  --ink: #111216;
  --muted: #747782;
  --line: rgba(17,18,22,.09);
  --blue: #007aff;
  --green: #34c759;
  --teal: #54d2c7;
  --rose: #ff8fab;
  --violet: #b8a7ff;
  --cream: #fff4ea;
  --danger: #ff3b30;
  --shadow: 0 24px 90px rgba(26, 27, 35, .12);
  --soft-shadow: 0 10px 28px rgba(26, 27, 35, .08);
  --radius-xl: 34px;
  --radius-lg: 26px;
  --radius-md: 18px;
  --sidebar: 282px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: radial-gradient(circle at 8% 0%, rgba(255,143,171,.32), transparent 27%), radial-gradient(circle at 92% 8%, rgba(84,210,199,.30), transparent 25%), radial-gradient(circle at 70% 92%, rgba(184,167,255,.24), transparent 30%), var(--bg); }
body { min-height: 100vh; margin: 0; color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-frame { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; }
.desktop-sidebar { height: 100vh; position: sticky; top: 0; padding: 22px; border-right: 1px solid var(--line); background: rgba(255,255,255,.48); backdrop-filter: blur(30px); display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark, .app-icon { width: 52px; height: 52px; border-radius: 17px; display: grid; place-items: center; color: #fff; font-weight: 900; letter-spacing: -.08em; background: linear-gradient(135deg, var(--blue), var(--teal) 55%, var(--rose)); box-shadow: 0 16px 35px rgba(0,122,255,.22); }
.brand strong { display: block; font-size: 18px; letter-spacing: -.04em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); }
.desktop-nav { display: grid; gap: 8px; }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; color: #565a66; border-radius: 16px; font-weight: 750; transition: .2s ease; }
.nav-item span { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 11px; background: rgba(0,122,255,.08); }
.nav-item:hover, .nav-item.active { color: var(--ink); background: rgba(255,255,255,.78); box-shadow: var(--soft-shadow); }
.trust-card { margin-top: auto; padding: 18px; border-radius: 24px; border: 1px solid rgba(255,255,255,.7); background: linear-gradient(145deg, rgba(255,255,255,.82), rgba(255,255,255,.45)); box-shadow: var(--soft-shadow); }
.trust-card strong { display: block; margin-bottom: 6px; }
.trust-card p { color: var(--muted); margin: 0; line-height: 1.45; font-size: 14px; }

.app-main { min-width: 0; padding: 22px; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
.ios-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 6px; text-transform: uppercase; letter-spacing: .14em; font-size: 11px; color: var(--blue); font-weight: 850; }
h1, h2, h3 { margin: 0; letter-spacing: -.055em; }
h1 { font-size: clamp(34px, 5vw, 58px); line-height: .95; }
h2 { font-size: clamp(24px, 3vw, 34px); line-height: 1; }
h3 { font-size: 22px; }
.muted { color: var(--muted); line-height: 1.55; }
.center { text-align: center; }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.primary-pill, .ghost-pill, .call-pill { min-height: 42px; border: 0; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 16px; font-weight: 850; transition: .2s ease; }
.primary-pill { color: #fff; background: linear-gradient(135deg, var(--blue), #5e5ce6); box-shadow: 0 14px 30px rgba(0,122,255,.24); }
.ghost-pill { color: var(--ink); background: rgba(255,255,255,.74); border: 1px solid var(--line); }
.call-pill { color: #fff; background: var(--green); }
.full { width: 100%; }
.primary-pill:hover, .ghost-pill:hover, .call-pill:hover, .circle-btn:hover, .mini-button:hover { transform: translateY(-1px); }
.flash { margin-bottom: 14px; padding: 13px 15px; border-radius: 18px; background: rgba(255,255,255,.82); border: 1px solid var(--line); box-shadow: var(--soft-shadow); }
.flash.success { color: #227e44; background: rgba(52,199,89,.12); }
.flash.error { color: #a92721; background: rgba(255,59,48,.12); }

.chat-app-card { min-height: calc(100vh - 132px); display: grid; grid-template-columns: minmax(320px, 390px) 1fr; border-radius: var(--radius-xl); overflow: hidden; background: rgba(255,255,255,.58); border: 1px solid rgba(255,255,255,.72); box-shadow: var(--shadow); backdrop-filter: blur(26px); }
.chat-list-pane { border-right: 1px solid var(--line); padding: 18px; min-width: 0; }
.ios-section-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; }
.ios-section-head strong { font-size: 26px; letter-spacing: -.055em; display: block; }
.ios-section-head span { color: var(--muted); font-size: 13px; }
.circle-btn { width: 38px; height: 38px; border-radius: 999px; display: grid; place-items: center; color: #fff; background: var(--blue); font-size: 25px; line-height: 1; box-shadow: 0 12px 28px rgba(0,122,255,.22); }
.search-pill { height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 14px; background: rgba(118,118,128,.12); color: var(--muted); margin-bottom: 14px; }
.search-pill input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--ink); }
.conversation-list { display: grid; gap: 6px; max-height: calc(100vh - 245px); overflow: auto; padding-right: 3px; }
.conversation-row { display: grid; grid-template-columns: 58px 1fr; gap: 12px; align-items: center; min-height: 72px; padding: 8px; border-radius: 18px; transition: .16s ease; }
.conversation-row:hover, .conversation-row.active { background: rgba(0,122,255,.09); }
.avatar { width: 48px; height: 48px; border-radius: 17px; display: grid; place-items: center; background: linear-gradient(135deg, rgba(0,122,255,.13), rgba(84,210,199,.18)); font-size: 24px; }
.avatar.xl { width: 58px; height: 58px; border-radius: 20px; font-size: 30px; }
.conversation-meta { min-width: 0; }
.conversation-meta div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.conversation-meta strong { min-width: 0; font-size: 16px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-meta time { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.conversation-meta p { margin: 4px 0 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.chat-thread-pane { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; background: linear-gradient(180deg, rgba(255,255,255,.68), rgba(247,247,249,.5)); }
.thread-header { min-height: 74px; padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(255,255,255,.64); backdrop-filter: blur(20px); }
.thread-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.thread-title strong { display: block; letter-spacing: -.02em; }
.thread-title span { color: var(--muted); font-size: 13px; }
.inline-form { margin: 0; }
.messages { padding: 20px; overflow: auto; display: flex; flex-direction: column; gap: 10px; background-image: radial-gradient(circle at 18px 18px, rgba(17,18,22,.035) 1px, transparent 1px); background-size: 22px 22px; }
.bubble { max-width: min(680px, 78%); padding: 10px 13px; border-radius: 20px; box-shadow: 0 6px 14px rgba(26,27,35,.05); }
.bubble small { display: block; font-size: 11px; opacity: .7; margin-bottom: 3px; }
.bubble p { margin: 0; line-height: 1.42; }
.bubble.parent { align-self: flex-end; color: #fff; background: linear-gradient(135deg, var(--blue), #5e5ce6); border-bottom-right-radius: 6px; }
.bubble.child { align-self: flex-end; color: #fff; background: linear-gradient(135deg, var(--green), #30b0c7); border-bottom-right-radius: 6px; }
.bubble.contact { align-self: flex-start; background: #fff; border-bottom-left-radius: 6px; }
.bubble.system { align-self: center; max-width: 80%; text-align: center; background: rgba(118,118,128,.12); color: var(--muted); box-shadow: none; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px; border-top: 1px solid var(--line); background: rgba(255,255,255,.76); }
.composer input { min-height: 48px; border: 1px solid var(--line); border-radius: 999px; padding: 0 16px; outline: 0; background: #fff; }
.composer button { min-height: 48px; border: 0; border-radius: 999px; padding: 0 18px; color: #fff; background: var(--blue); font-weight: 850; }
.no-thread { min-height: 100%; display: grid; place-items: center; align-content: center; text-align: center; gap: 12px; padding: 30px; }
.no-thread .app-icon { margin: 0 auto; }

.split-grid { display: grid; grid-template-columns: minmax(320px,.75fr) minmax(0,1.25fr); gap: 18px; }
.ios-card { padding: 20px; border-radius: var(--radius-xl); background: rgba(255,255,255,.72); border: 1px solid rgba(255,255,255,.74); box-shadow: var(--shadow); backdrop-filter: blur(24px); }
.ios-card.full { grid-column: 1 / -1; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-height: 30px; border-radius: 999px; padding: 0 12px; background: rgba(0,122,255,.11); color: var(--blue); font-size: 12px; font-weight: 850; }
.badge.safe { color: #227e44; background: rgba(52,199,89,.13); }
.stack-form { display: grid; gap: 12px; }
label { display: grid; gap: 7px; font-weight: 800; font-size: 13px; }
input, select { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 16px; padding: 0 13px; outline: 0; background: rgba(255,255,255,.86); color: var(--ink); }
input:focus, select:focus { border-color: rgba(0,122,255,.42); box-shadow: 0 0 0 5px rgba(0,122,255,.09); }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 12px; background: rgba(118,118,128,.08); border-radius: 16px; }
.check-row input { width: auto; min-height: auto; accent-color: var(--blue); }
.contact-list { display: grid; gap: 10px; }
.contact-row { display: grid; grid-template-columns: 58px 1fr auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.6); }
.contact-info { min-width: 0; }
.contact-info strong { display: block; }
.contact-info span { display: block; color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.contact-info input { min-height: 34px; font-size: 12px; color: var(--muted); }
.contact-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.contact-actions form { margin: 0; }
.mini-button { min-height: 32px; border: 0; border-radius: 12px; padding: 0 10px; font-weight: 850; font-size: 12px; background: rgba(118,118,128,.12); color: var(--ink); }
.mini-button.approved { color: #227e44; background: rgba(52,199,89,.13); }
.mini-button.blocked, .mini-button.danger { color: #9c211c; background: rgba(255,59,48,.13); }
.empty-state { padding: 22px; border-radius: 20px; border: 1px dashed var(--line); color: var(--muted); background: rgba(255,255,255,.44); text-align: center; line-height: 1.5; }

.child-body { background: radial-gradient(circle at 50% 0%, rgba(255,143,171,.45), transparent 32%), #fff7ef; }
.child-home, .child-chat-screen { width: min(980px, 100%); min-height: calc(100vh - 46px); margin: 0 auto; padding: 20px; border-radius: 38px; background: rgba(255,255,255,.65); border: 1px solid rgba(255,255,255,.75); box-shadow: var(--shadow); backdrop-filter: blur(26px); }
.child-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 26px; }
.child-top p { margin: 0 0 4px; color: var(--muted); font-weight: 800; }
.child-top h1 { font-size: clamp(34px, 6vw, 62px); }
.safe-dot { color: var(--green); text-shadow: 0 0 0 8px rgba(52,199,89,.13); }
.child-prompt { font-size: clamp(24px, 5vw, 42px); font-weight: 900; letter-spacing: -.055em; margin-bottom: 18px; }
.child-contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.child-person-card { min-height: 245px; display: grid; place-items: center; text-align: center; padding: 20px; border-radius: 34px; background: linear-gradient(145deg, rgba(255,255,255,.88), rgba(255,255,255,.54)); box-shadow: var(--soft-shadow); }
.child-avatar { width: 104px; height: 104px; border-radius: 34px; display: grid; place-items: center; font-size: 58px; background: linear-gradient(135deg, rgba(0,122,255,.14), rgba(255,143,171,.22)); margin-bottom: 10px; }
.child-person-card strong { font-size: 26px; letter-spacing: -.045em; }
.child-person-card span { color: var(--muted); font-weight: 800; }
.child-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin-top: 14px; }
.child-actions a, .child-actions button { min-height: 46px; border: 0; border-radius: 999px; display: grid; place-items: center; font-weight: 900; }
.child-actions a { background: rgba(0,122,255,.1); color: var(--blue); }
.child-actions button { width: 100%; color: #fff; background: var(--green); }
.child-safe-banner { margin-top: 18px; padding: 18px; border-radius: 24px; color: #227e44; background: rgba(52,199,89,.12); }
.child-safe-banner p { margin: 5px 0 0; color: #427b53; }
.child-thread { border-radius: 24px; border: 1px solid var(--line); }
.back-link { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 999px; background: rgba(118,118,128,.12); font-size: 32px; }
.child-messages { height: calc(100vh - 330px); min-height: 360px; margin: 12px 0; border-radius: 28px; background-color: rgba(255,255,255,.48); }
.quick-replies { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.quick-replies form { margin: 0; }
.quick-replies button { white-space: nowrap; min-height: 40px; border: 0; border-radius: 999px; padding: 0 14px; background: rgba(0,122,255,.1); color: var(--blue); font-weight: 850; }

.call-body { background: #121216; }
.call-screen { min-height: calc(100vh - 44px); display: grid; align-content: center; gap: 16px; }
.call-stage { position: relative; min-height: min(720px, calc(100vh - 190px)); border-radius: 42px; overflow: hidden; display: grid; place-items: center; color: #fff; background: radial-gradient(circle at 50% 10%, rgba(255,143,171,.35), transparent 34%), linear-gradient(135deg, #181820, #353245); box-shadow: 0 30px 90px rgba(0,0,0,.35); }
.call-blur { position: absolute; inset: 0; background: radial-gradient(circle, transparent 25%, rgba(0,0,0,.25)); pointer-events: none; }
#localVideo { position: absolute; right: 18px; top: 18px; width: min(210px, 34vw); aspect-ratio: 9/16; object-fit: cover; border-radius: 28px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.22); z-index: 3; box-shadow: 0 16px 55px rgba(0,0,0,.3); }
.remote-grid { position: absolute; inset: 0; display: grid; place-items: center; z-index: 1; }
.remote-grid video { width: 100%; height: 100%; object-fit: cover; }
.call-person { position: relative; z-index: 2; text-align: center; }
.call-avatar { width: 142px; height: 142px; border-radius: 48px; display: grid; place-items: center; margin: 0 auto 18px; font-size: 76px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.24); backdrop-filter: blur(18px); }
.call-person p { color: rgba(255,255,255,.74); }
.call-controls { display: flex; justify-content: center; gap: 12px; }
.round-control { width: 72px; height: 72px; border-radius: 999px; border: 0; display: grid; place-items: center; color: #fff; font-weight: 900; background: rgba(255,255,255,.17); backdrop-filter: blur(18px); }
.round-control.end { background: var(--danger); }
.call-note { text-align: center; color: rgba(255,255,255,.68); margin: 0; font-size: 13px; }

.safety-list, .role-list, .architecture-list { display: grid; gap: 12px; }
.safety-item, .role-list div { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 20px; background: rgba(255,255,255,.62); border: 1px solid var(--line); }
.safety-item > span { width: 28px; height: 28px; border-radius: 999px; display: grid; place-items: center; flex: 0 0 28px; color: #227e44; background: rgba(52,199,89,.13); font-weight: 900; }
.safety-item p, .role-list span { margin: 4px 0 0; color: var(--muted); line-height: 1.45; }
.architecture-list { grid-template-columns: repeat(2, 1fr); }
.architecture-list span { min-height: 54px; display: grid; place-items: center; border-radius: 18px; background: rgba(0,122,255,.08); font-weight: 850; }
.code-block { white-space: pre-wrap; overflow: auto; padding: 16px; border-radius: 18px; color: #fff; background: #1c1c1e; }

.auth-body .app-frame { display: block; }
.auth-main { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.auth-screen { width: min(1050px, 100%); display: grid; grid-template-columns: 1fr 420px; gap: 18px; padding: 18px; border-radius: 38px; border: 1px solid rgba(255,255,255,.75); background: rgba(255,255,255,.58); box-shadow: var(--shadow); backdrop-filter: blur(28px); }
.auth-screen.wide { grid-template-columns: 1fr 460px; }
.auth-copy { display: grid; align-content: center; gap: 14px; padding: clamp(20px, 5vw, 48px); }
.auth-copy p:not(.eyebrow) { color: var(--muted); font-size: 18px; line-height: 1.6; }
.auth-card { display: grid; align-content: center; gap: 13px; padding: 24px; border-radius: 28px; border: 1px solid var(--line); background: rgba(255,255,255,.78); }
.install-wrap { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.install-card { width: min(900px, 100%); padding: 26px; border-radius: 34px; border: 1px solid rgba(255,255,255,.76); background: rgba(255,255,255,.72); box-shadow: var(--shadow); backdrop-filter: blur(24px); }
.install-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-section { display: grid; gap: 12px; padding: 16px; border-radius: 24px; border: 1px solid var(--line); background: rgba(255,255,255,.58); }

.mobile-tabbar { display: none; }

@media (max-width: 1080px) {
  .app-frame { grid-template-columns: 1fr; }
  .desktop-sidebar { display: none; }
  .app-main { padding: 16px; padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .ios-header { margin-top: 4px; }
  .mobile-tabbar { position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 40; height: 68px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 7px; border-radius: 24px; background: rgba(255,255,255,.82); border: 1px solid rgba(255,255,255,.78); box-shadow: 0 18px 55px rgba(26,27,35,.18); backdrop-filter: blur(24px); }
  .tab-item { display: grid; place-items: center; align-content: center; gap: 3px; color: var(--muted); border-radius: 18px; font-size: 19px; }
  .tab-item small { font-size: 10px; font-weight: 800; }
  .tab-item.active { color: var(--blue); background: rgba(0,122,255,.09); }
}

@media (max-width: 860px) {
  .ios-header { align-items: stretch; display: grid; }
  .header-actions { justify-content: stretch; }
  .header-actions a { flex: 1; }
  .chat-app-card { min-height: calc(100vh - 185px); grid-template-columns: 1fr; }
  .chat-list-pane { border-right: 0; border-bottom: 1px solid var(--line); }
  .conversation-list { max-height: 285px; }
  .thread-header { position: sticky; top: 0; z-index: 2; }
  .messages { min-height: 390px; max-height: 54vh; }
  .split-grid, .auth-screen, .auth-screen.wide, .install-grid { grid-template-columns: 1fr; }
  .contact-row { grid-template-columns: 58px 1fr; }
  .contact-actions { grid-column: 1 / -1; justify-content: stretch; }
  .contact-actions form { flex: 1; }
  .mini-button { width: 100%; }
}

@media (max-width: 560px) {
  h1 { font-size: 38px; }
  .app-main { padding: 12px; padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .chat-app-card, .ios-card, .auth-screen, .install-card, .child-home, .child-chat-screen { border-radius: 26px; }
  .chat-list-pane, .ios-card, .auth-card { padding: 14px; }
  .conversation-row { grid-template-columns: 52px 1fr; }
  .avatar.xl { width: 52px; height: 52px; border-radius: 18px; font-size: 27px; }
  .thread-header { min-height: 66px; padding: 10px; }
  .call-pill { min-height: 38px; padding: 0 12px; }
  .messages { padding: 12px; }
  .bubble { max-width: 88%; }
  .composer { grid-template-columns: 1fr; }
  .composer button { width: 100%; }
  .two-cols, .architecture-list { grid-template-columns: 1fr; }
  .child-contact-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .child-person-card { min-height: 205px; border-radius: 26px; padding: 14px; }
  .child-avatar { width: 80px; height: 80px; border-radius: 26px; font-size: 44px; }
  .child-person-card strong { font-size: 21px; }
  .child-actions { grid-template-columns: 1fr; }
  #localVideo { width: 120px; border-radius: 20px; }
  .call-avatar { width: 118px; height: 118px; border-radius: 38px; font-size: 64px; }
  .round-control { width: 62px; height: 62px; }
}
