/* Her screen (or a child's): one calm app in roleEdge's design language, sized for an older reader (18px+ body, 56px
   targets). Black marks what can be tapped; the caregiver's words, the assistant's and family relays are told apart by
   their labels (T4), not by a colour each. */
@import url("tokens.css");
@import url("studio.css");

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--page); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { flex: none; display: block; }

/* frame: standalone draws the device; inside the Studio the Studio draws it */
.frame { height: 100%; display: grid; place-items: center; }
body:not(.mirror) .screen { width: 360px; height: 740px; border-radius: 40px; box-shadow: 0 0 0 9px #111, 0 0 0 10px #2a2a2a, var(--shadow-lg); }
/* on a real phone the app is the screen: no drawn device, no second status bar */
@media (max-width: 480px), (max-height: 760px) and (max-width: 900px) {
  body:not(.mirror) .screen { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; box-shadow: none; }
  body:not(.mirror) .sbar { display: none; }
  body:not(.mirror) .top { padding-top: max(12px, env(safe-area-inset-top)); }
}
body.mirror { background: var(--canvas); }
body.mirror .screen { width: 100%; height: 100%; }
.screen { position: relative; overflow: hidden; display: flex; flex-direction: column; background: var(--canvas); isolation: isolate; }

.sbar { flex: none; height: 40px; padding: 14px 26px 0; display: flex; justify-content: space-between; font: 600 14px var(--font); font-variant-numeric: tabular-nums; }
.sbar-r { display: flex; align-items: center; gap: 6px; }
.sig { display: flex; align-items: flex-end; gap: 2px; height: 10px; } .sig b { width: 3px; background: var(--ink); border-radius: 1px; }
.sig b:nth-child(1) { height: 4px; } .sig b:nth-child(2) { height: 6px; } .sig b:nth-child(3) { height: 8px; } .sig b:nth-child(4) { height: 10px; }
.bat { width: 22px; height: 11px; border: 1.5px solid var(--ink); border-radius: 3px; padding: 1.5px; } .bat b { display: block; height: 100%; width: 75%; background: var(--ink); border-radius: 1px; }

.top { flex: none; display: flex; align-items: center; gap: 12px; padding: 10px 18px 14px; border-bottom: 1px solid var(--hairline); }
.face { width: 48px; height: 48px; flex: none; border-radius: 50%; overflow: hidden; background: var(--surface-card); color: var(--body); display: grid; place-items: center; font-weight: 600; font-size: 18px; }
.face img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.who { flex: 1; min-width: 0; }
.name { font-size: 22px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.sub { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.sub i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.brand { display: grid; }

/* feed */
.feed { flex: 1; overflow-y: auto; padding: 16px 16px 20px; display: flex; flex-direction: column; gap: 14px; background: var(--page); }
.empty { margin: auto; padding: 0 24px; text-align: center; color: var(--muted); font-size: 18px; line-height: 1.5; }
.card { background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-2xl); padding: 18px; box-shadow: var(--shadow-sm); animation: rise .35s var(--ease); }
.card.mine { align-self: flex-end; max-width: 82%; padding: 14px 16px; background: var(--brand); border-color: var(--brand); color: #fff; font-size: 18px; line-height: 1.45; border-radius: 16px 16px 4px 16px; }
.card.alert { border: 2px solid var(--urgent); }
.from { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 14px; color: var(--muted); }
.from .tag { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: var(--r-sm); border: 1px solid var(--ink); background: var(--ink); color: #fff; font-size: 13px; font-weight: 500; }
.from .tag.assistant { border-color: var(--hairline); background: var(--surface-card); color: var(--body); }
.from .tag i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.title { font-size: 22px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.spoken { margin-top: 8px; font-size: 18px; line-height: 1.55; color: var(--body); }
.gloss { margin-top: 6px; font-size: 14px; color: var(--muted); }
.steps { margin: 12px 0 0; padding-left: 22px; font-size: 18px; line-height: 1.55; }
.listen { margin-top: 14px; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 0 16px 0 8px; border: 1px solid var(--line-strong); border-radius: var(--r-xl); background: var(--canvas); font-size: 17px; font-weight: 600; }
.listen .pb { width: 42px; height: 42px; border-radius: var(--r-lg); background: var(--accent); color: #fff; display: grid; place-items: center; }
.listen .wv { flex: 1; display: flex; align-items: center; gap: 3px; height: 22px; } .listen .wv i { flex: 1; height: 30%; border-radius: 2px; background: var(--surface-strong); }
.listen .wv i:nth-child(3n) { height: 75%; } .listen .wv i:nth-child(4n) { height: 50%; }
.replies { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.replies button { min-height: 56px; padding: 0 16px; border-radius: var(--r-xl); border: 1px solid var(--line-strong); background: var(--canvas); font-size: 18px; font-weight: 600; text-align: left; }
.call { display: block; margin-top: 12px; padding: 18px; border-radius: var(--r-xl); background: var(--urgent); color: #fff; text-align: center; font-size: 22px; font-weight: 600; text-decoration: none; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* a Studio pack: the question to talk about, then one row per moment */
.ask { margin-top: 12px; padding: 14px 16px; border-left: 3px solid var(--ink); background: var(--surface); border-radius: 0 var(--r-lg) var(--r-lg) 0; font-size: 18px; line-height: 1.5; }
.fmts { margin-top: 14px; display: flex; flex-direction: column; border: 1px solid var(--hairline); border-radius: var(--r-lg); overflow: hidden; }
.fmt { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 14px; min-height: 64px; padding: 0 14px; border: 0; border-bottom: 1px solid var(--hairline-soft); background: var(--canvas); text-align: left; font-size: 18px; font-weight: 600; }
.fmt:last-child { border-bottom: 0; }
.fmt:active { background: var(--surface); }
.fmt .fi { width: 44px; height: 44px; border-radius: var(--r-lg); display: grid; place-items: center; background: var(--surface-card); color: var(--ink); }
.fmt .end { color: var(--accent); } .fmt .end.done { color: var(--ok); }

/* talk bar */
.talk { flex: none; display: flex; align-items: flex-end; gap: 10px; padding: 12px 14px 22px; border-top: 1px solid var(--hairline); background: var(--canvas); }
.talk textarea { flex: 1; resize: none; min-height: 56px; max-height: 120px; padding: 15px 16px; border-radius: var(--r-xl); border: 1px solid var(--line-strong); background: var(--canvas); font-size: 18px; outline: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.talk textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
#mic, #reply-send { width: 56px; height: 56px; flex: none; border-radius: var(--r-xl); border: 0; display: grid; place-items: center; }
#mic { background: var(--accent); color: #fff; } #mic.rec { background: var(--urgent); animation: pulse 1.2s infinite; }
#reply-send { background: var(--surface-card); color: var(--ink); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .5); } 50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); } }

/* arrival banner */
.banner { position: absolute; top: 44px; left: 12px; right: 12px; z-index: 30; display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: center; padding: 12px 14px;
  border: 1px solid var(--hairline); border-radius: var(--r-xl); background: rgba(255, 255, 255, .96); backdrop-filter: blur(16px); box-shadow: var(--shadow-lg), var(--shadow-md);
  text-align: left; animation: drop .45s var(--ease); }
.banner .bi { width: 40px; height: 40px; display: grid; place-items: center; }
.banner b { display: block; font-size: 15px; } .banner span { display: block; font-size: 15px; color: var(--body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner small { font-size: 12px; color: var(--muted); }
@keyframes drop { from { transform: translateY(-130%); opacity: 0; } to { transform: none; opacity: 1; } }

/* the Studio sheet: full screen, one format at a time */
.sheet { position: absolute; inset: 0; z-index: 25; display: flex; flex-direction: column; background: var(--canvas); animation: sheet-up .4s var(--ease); }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 48px 16px 10px; }
.sheet-close { width: 44px; height: 44px; border-radius: var(--r-lg); border: 1px solid var(--line-strong); background: var(--canvas); display: grid; place-items: center; flex: none; }
.sheet-title { flex: 1; min-width: 0; font-size: 17px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-tabs { display: flex; gap: 6px; padding: 4px 16px 12px; overflow-x: auto; border-bottom: 1px solid var(--hairline-soft); }
.sheet-tabs button { flex: none; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: var(--r-lg); border: 1px solid var(--line-strong); background: var(--canvas); font-size: 15px; font-weight: 600; color: var(--body); }
.sheet-tabs button[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent); }
.sheet-body { flex: 1; overflow-y: auto; padding: 18px 18px 36px; }

/* talking avatar stage */
.stage { flex: none; padding: 12px 16px 14px; border-bottom: 1px solid var(--hairline); background: var(--canvas); animation: rise .3s var(--ease); }
.portrait { position: relative; border-radius: var(--r-2xl); overflow: hidden; aspect-ratio: 4 / 3; background: var(--surface-card); }
.portrait img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 28%; display: block; transform-origin: 50% 85%; animation: breathe 5s ease-in-out infinite; }
.portrait img.talking { animation: sway 2.8s ease-in-out infinite; }
.portrait canvas { width: 100%; height: 100%; display: block; background: linear-gradient(180deg, #f3f4f6, #e5e7eb); }
.stage-badge { position: absolute; left: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r-pill); background: rgba(17, 17, 17, .72); color: #fff; font-size: 14px; font-weight: 600; backdrop-filter: blur(6px); }
.stage-badge .mark { display: inline-flex; color: #d4d4d8; }
.stage-close { position: absolute; right: 10px; top: 10px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(17, 17, 17, .55); color: #fff; display: grid; place-items: center; }
.caption { margin-top: 12px; font-size: 20px; line-height: 1.45; min-height: 2.9em; max-height: 7.5em; overflow-y: auto; color: var(--muted); }
.caption .said { color: var(--ink); }
.stage-step { margin-top: 6px; font-size: 14px; color: var(--muted); min-height: 1.2em; }
.stage-controls { margin-top: 10px; display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.stage-controls .soft { min-height: 52px; border: 1px solid var(--hairline); background: var(--canvas); border-radius: var(--r-lg); padding: 12px; font-size: 18px; font-weight: 600; }
.stage-controls .soft:disabled { opacity: .35; }
.stage-controls .round { width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; }
.stage-controls .round.playing { background: var(--ink-soft); }
.stage.idle .stage-controls, .stage.idle .stage-step { display: none; }
.stage.idle .portrait { aspect-ratio: 16 / 7; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.012); } }
@keyframes sway { 0%, 100% { transform: rotate(-.6deg); } 50% { transform: rotate(.6deg) translateY(-1px); } }

@media (prefers-reduced-motion: reduce) { .sheet, .banner, .card, .stage, .portrait img { animation: none !important; } }

.replies .order { display: inline-flex; align-items: center; gap: 8px; background: var(--accent); color: #fff; border-color: var(--accent); }

/* the family relay: a grandchild and their grandparent */
.from .tag.family { border-color: var(--line-strong); background: var(--canvas); color: var(--ink); }
.card.relay .relay-pic { display: block; width: 100%; margin-top: 12px; border-radius: var(--r-lg); aspect-ratio: 1; object-fit: cover; background: var(--surface); }
.card.mine .relay-state { display: block; margin-top: 6px; font-size: 13px; color: var(--on-brand-soft); }
.replies .answer { display: flex; align-items: center; gap: 10px; background: var(--accent); border-color: var(--accent); color: #fff; }
.relay-chip { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-top: 1px solid var(--hairline);
  background: var(--surface-card); color: var(--ink); font-size: 14px; font-weight: 600; }
.relay-chip[hidden] { display: none; }
.relay-chip span { flex: 1; }
.relay-chip button { min-height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--canvas); color: var(--ink); font: 600 13px var(--font); }

/* a delivery answer, drawn: the truck rolls to "on the way" when the card arrives */
.deliv { margin-top: 14px; padding: 14px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--hairline); }
.dl-head { display: flex; align-items: center; gap: 12px; }
.dl-ic { width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--ink); color: #fff; } .dl-ic svg { width: 24px; height: 24px; }
.dl-head small { display: block; font-size: 14px; color: var(--muted); } .dl-head b { display: block; font-size: 20px; line-height: 1.3; }
.dl-track { position: relative; height: 8px; margin: 18px 6px 0; border-radius: 8px; background: var(--surface-strong); }
.dl-fill { position: absolute; inset: 0; border-radius: 8px; background: var(--ink); transform-origin: 0 50%; animation: dl-fill 1.8s var(--ease) .3s both; }
.dl-truck { position: absolute; top: 50%; left: 62%; width: 32px; height: 32px; margin: -16px 0 0 -16px; border-radius: 50%; display: grid; place-items: center; background: #fff;
  box-shadow: 0 0 0 2px var(--ink), var(--shadow-sm); color: var(--ink); animation: dl-truck 1.8s var(--ease) .3s both; }
.dl-truck svg { width: 18px; height: 18px; }
.dl-steps { display: flex; justify-content: space-between; margin-top: 12px; font-size: 14px; color: var(--muted); }
.dl-src { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--hairline); font-size: 14px; color: var(--body); }
@keyframes dl-fill { from { transform: scaleX(.08); } to { transform: scaleX(.62); } }
@keyframes dl-truck { from { left: 8%; } to { left: 62%; } }
@media (prefers-reduced-motion: reduce) { .dl-fill, .dl-truck { animation: none; } .dl-fill { transform: scaleX(.62); } }

/* a product she asked about or that was ordered */
.prod-row { display: flex; align-items: center; gap: 12px; margin: 10px 0 4px; padding: 10px; border-radius: var(--r-xl); border: 1px solid var(--hairline); background: #fff; }
.prod-row img { width: 64px; height: 64px; flex: none; border-radius: var(--r-lg); object-fit: contain; background: #fff; }
.prod-row span { font-size: 16px; font-weight: 600; line-height: 1.35; } .prod-row small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }

/* under a moment: the products it recommends and the links the app checked */
.sheet-extras:empty { display: none; }
.sheet-extras { margin-top: 18px; display: grid; gap: 12px; }
.x-products { display: grid; gap: 10px; }
.x-product { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--hairline); border-radius: var(--r-lg); background: var(--canvas); }
.x-product img, .x-noimg { width: 64px; height: 64px; border-radius: var(--r-md); object-fit: contain; background: #fff; display: grid; place-items: center; color: var(--muted); }
.x-product b { display: block; font-size: 16px; line-height: 1.3; } .x-product small { display: block; font-size: 14px; color: var(--body); line-height: 1.4; }
.x-want { height: 40px; padding: 0 14px; border: 0; border-radius: var(--r-md); background: var(--ink); color: #fff; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.x-want:disabled { opacity: .5; }
.x-links { display: grid; gap: 8px; }
.x-link { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--hairline); border-radius: var(--r-lg); color: var(--ink); text-decoration: none; background: var(--canvas); }
.x-link b { display: block; font-size: 15px; } .x-link small { display: block; font-size: 13px; color: var(--muted); }

/* compact: the avatar is a strip, not half the screen, so her messages, choices and the reply box have the room */
.stage { padding: 10px 14px 12px; }
.portrait { aspect-ratio: 2 / 1; border-radius: var(--r-2xl); }
.stage.idle .portrait { aspect-ratio: 3 / 1; }
.portrait img { object-position: 50% 40%; } /* a strip of the face: keep the mouth in view, it moves with the words */
.caption { margin-top: 10px; font-size: 18px; line-height: 1.4; min-height: 0; max-height: 5.7em; scroll-behavior: smooth; }
.stage.idle .caption { margin-top: 8px; font-size: 15px; max-height: 2.8em; }
.stage-step { margin-top: 4px; font-size: 13px; min-height: 0; }
.stage-controls { margin-top: 8px; gap: 10px; }
.stage-controls .soft { min-height: 46px; padding: 8px 10px; font-size: 16px; }
.stage-controls .round { width: 54px; height: 54px; }
.stage-badge { left: 10px; bottom: 10px; padding: 4px 10px; font-size: 13px; }
.stage-close { width: 32px; height: 32px; right: 8px; top: 8px; }
@media (max-height: 700px) { .portrait { aspect-ratio: 5 / 2; } .stage.idle .portrait { aspect-ratio: 4 / 1; } }
