/* 和宠物说话 (spec §48): the chat screen over the pet room (pets/talk.js, .ptk-), the room's way in (talk-entry.js,
   .ptk-entry), the parents' 「聊天」 tab (talk-parent.js, .ptc-) and the standalone preview host (views/pets-talk-dev.js,
   .ptd-). Light only (spec §45). What moves moves with transform and opacity. Side-by-side buttons and cards are
   equal (grids of minmax(0, 1fr), one class each, spec §12). The microphone: pressed the moment a finger is down,
   no long-press menu or magnifier (touch-action: none, spec §47.5). */
:root {
  --ptk-mic: 120px;
  --ptk-entry: 96px;
  --ptk-entry-closed: 64px;
  --ptk-mic-1: #FFA27A;
  --ptk-mic-2: #F2704A;
  --ptk-mic-ink: #FFFFFF;
  --ptk-mic-shadow: 0 2px 4px rgba(150, 60, 30, 0.18), 0 12px 28px rgba(242, 112, 74, 0.32);
  --ptk-mic-calm-1: #B9A8EC;
  --ptk-mic-calm-2: #8C78D8;
  --ptk-ring: #FFC233;
  --ptk-ring-low: #F28A4A;
  --ptk-ring-track: rgba(42, 30, 53, 0.10);
  --ptk-halo: rgba(242, 112, 74, 0.22);
  --ptk-halo-calm: rgba(140, 120, 216, 0.20);
  --ptk-glass: rgba(255, 255, 255, 0.92);
  --ptk-glass-line: rgba(42, 30, 53, 0.06);
  --ptk-shadow: 0 1px 2px rgba(62, 40, 20, 0.06), 0 8px 22px rgba(62, 40, 20, 0.10);
  --ptk-ink: var(--ink);
  --ptk-heard: rgba(42, 30, 53, 0.64);
  --ptk-closed: #E7E1EA;
  --ptk-closed-ink: rgba(42, 30, 53, 0.64);
  --ptk-help: #FFF6E5;
  --ptk-help-line: rgba(199, 119, 0, 0.25);
  --ptc-bar-bg: rgba(42, 30, 53, 0.08);
  --ptc-bar: #F2704A;
  --ptc-bar-saving: #C77700;
  --ptc-bar-paused: #C02A32;
  --ptc-urgent: #C02A32;
  --ptc-urgent-soft: #FFE5E3;
  --ptc-watch: #8A5600;
  --ptc-watch-soft: #FFF0CC;
  --ptc-focus: rgba(242, 112, 74, 0.55);
  --ptd-wall-1: #EAF3FC;
  --ptd-wall-2: #DCEAF8;
  --ptd-floor-1: #F4E3C7;
  --ptd-floor-2: #EAD1AA;
  --ptd-cat: #F4A259;
  --ptd-cat-light: #FFE2C2;
  --ptd-dog: #E8D2B4;
  --ptd-dog-ear: #B9824C;
  --ptd-face-ink: #3A2A20;
  --ptd-cheek: rgba(242, 112, 74, 0.35);
}

/* ---------- the chat screen (a layer over the room) ---------- */
.ptk {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  justify-items: center;
  gap: 12px;
  padding: calc(var(--safe-top) + 14px) calc(var(--safe-right) + 18px) calc(var(--safe-bottom) + 22px) calc(var(--safe-left) + 18px);
  pointer-events: none;
  color: var(--ptk-ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.ptk > * { pointer-events: auto; }
.ptk-leave {
  grid-row: 1;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  min-height: 52px;
  padding: 0 22px;
  border: 1px solid var(--ptk-glass-line);
  border-radius: var(--r-pill);
  background: var(--ptk-glass);
  box-shadow: var(--ptk-shadow);
  font-size: 18px;
  font-weight: 700;
  color: var(--ptk-ink);
  touch-action: manipulation;
  transition: transform var(--dur-1) var(--ease-out);
}
.ptk-leave:active { transform: scale(0.96); }

.ptk-words {
  grid-row: 3;
  display: grid;
  justify-items: center;
  gap: 6px;
  align-content: end;
  width: min(100%, 640px);
  min-height: 78px;
  pointer-events: none;
}
.ptk-heard {
  max-width: 100%;
  padding: 2px 12px;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ptk-heard);
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.ptk-caption {
  display: flex;
  align-items: baseline;
  gap: 8px;
  max-width: 100%;
  padding: 10px 18px;
  border-radius: var(--r-l);
  background: var(--ptk-glass);
  box-shadow: var(--ptk-shadow);
  font-size: 20px;
  line-height: 1.45;
  font-weight: 600;
  animation: ptk-rise var(--dur-2) var(--ease-out);
}
.ptk-caption-who { flex-shrink: 0; font-size: 14px; font-weight: 700; color: var(--text-2); }
.ptk-caption-text { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

.ptk-dock { grid-row: 4; display: grid; justify-items: center; gap: 10px; }
.ptk-mic-wrap { position: relative; display: grid; place-items: center; width: calc(var(--ptk-mic) + 36px); height: calc(var(--ptk-mic) + 36px); }
.ptk-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.ptk-ring circle { fill: none; stroke-width: 5; stroke-linecap: round; }
.ptk-ring-track { stroke: var(--ptk-ring-track); }
.ptk-ring-left { stroke: var(--ptk-ring); transition: stroke-dashoffset 900ms linear; }
.ptk[data-low="true"] .ptk-ring-left { stroke: var(--ptk-ring-low); }
.ptk[data-serious="true"] .ptk-ring, .ptk[data-mic="denied"] .ptk-ring, .ptk[data-mic="no_mic"] .ptk-ring,
.ptk[data-mic="busy"] .ptk-ring, .ptk[data-mic="unsupported"] .ptk-ring, .ptk[data-mic="failed"] .ptk-ring { opacity: 0.35; }
.ptk-halo {
  position: absolute;
  width: var(--ptk-mic);
  height: var(--ptk-mic);
  border-radius: 50%;
  background: var(--ptk-halo);
  opacity: 0;
  transition: transform 120ms linear, opacity var(--dur-1) var(--ease-out);
  pointer-events: none;
}
.ptk[data-state="listening"] .ptk-halo { opacity: 1; }
/* 连着聊: listening by itself for the next words — a soft halo that breathes (§48.2a). */
.ptk[data-armed="true"][data-state="ready"] .ptk-halo { opacity: 0.7; animation: ptk-wait 1.8s var(--ease-out) infinite; }
.ptk[data-serious="true"] .ptk-halo { background: var(--ptk-halo-calm); }
.ptk-mic {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--ptk-mic);
  height: var(--ptk-mic);
  border: 0;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--ptk-mic-1), var(--ptk-mic-2));
  box-shadow: var(--ptk-mic-shadow);
  color: var(--ptk-mic-ink);
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--dur-1) var(--ease-out), opacity var(--dur-2) var(--ease-out);
}
.ptk-mic svg { width: 52px; height: 52px; }
.ptk-mic.is-down, .ptk[data-state="listening"] .ptk-mic { transform: scale(0.94); }
.ptk[data-serious="true"] .ptk-mic { background: linear-gradient(160deg, var(--ptk-mic-calm-1), var(--ptk-mic-calm-2)); }
.ptk[data-state="connecting"] .ptk-mic, .ptk[data-mic="denied"] .ptk-mic, .ptk[data-mic="no_mic"] .ptk-mic,
.ptk[data-mic="busy"] .ptk-mic, .ptk[data-mic="unsupported"] .ptk-mic, .ptk[data-mic="failed"] .ptk-mic { opacity: 0.45; }
.ptk[data-state="thinking"] .ptk-mic { animation: ptk-breathe 1.6s var(--ease-out) infinite; }
.ptk[data-serious="true"][data-state="thinking"] .ptk-mic { animation: none; }
/* A press that cannot begin yet (still connecting): a small shake, so it is not a press that did nothing. */
.ptk-mic.is-busy { animation: ptk-busy 360ms var(--ease-out) 1; }
.ptk-hint { min-height: 26px; font-size: 18px; font-weight: 700; color: var(--ptk-ink); text-align: center; }

.ptk-help {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(calc(100% - 36px), 460px);
  transform: translate(-50%, -50%);
  display: grid;
  gap: 10px;
  padding: 20px 22px;
  border: 1px solid var(--ptk-help-line);
  border-radius: var(--r-l);
  background: var(--ptk-help);
  box-shadow: var(--ptk-shadow);
}
.ptk-help-title { font-size: 19px; }
.ptk-help-lead { font-size: 15px; color: var(--text-2); }
.ptk-help-list { display: grid; gap: 6px; padding-left: 20px; font-size: 15px; line-height: 1.45; }
.ptk-help .btn { justify-self: end; }

@keyframes ptk-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes ptk-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes ptk-wait { 0%, 100% { transform: scale(1.04); } 50% { transform: scale(1.18); } }
@keyframes ptk-busy { 0%, 100% { translate: 0 0; } 25% { translate: -6px 0; } 75% { translate: 6px 0; } }

/* ---------- the way in (the room's microphone) ---------- */
.ptk-entry { display: grid; justify-items: center; }
.ptk-entry[hidden] { display: none; }
.ptk-entry-btn {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ptk-ink);
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.ptk-entry-mic {
  display: grid;
  place-items: center;
  width: var(--ptk-entry);
  height: var(--ptk-entry);
  border-radius: 50%;
  background: linear-gradient(160deg, var(--ptk-mic-1), var(--ptk-mic-2));
  box-shadow: var(--ptk-mic-shadow);
  color: var(--ptk-mic-ink);
  transition: transform var(--dur-1) var(--ease-out);
}
.ptk-entry-mic svg { width: 44px; height: 44px; }
.ptk-entry-btn:active .ptk-entry-mic { transform: scale(0.94); }
.ptk-entry-label { font-size: 16px; font-weight: 700; white-space: nowrap; }
.ptk-entry[data-mode="closed"] .ptk-entry-mic {
  width: var(--ptk-entry-closed);
  height: var(--ptk-entry-closed);
  margin: calc((var(--ptk-entry) - var(--ptk-entry-closed)) / 2);
  background: var(--ptk-closed);
  box-shadow: none;
  color: var(--ptk-closed-ink);
}
.ptk-entry[data-mode="closed"] .ptk-entry-mic svg { width: 30px; height: 30px; }

/* ---------- the parents' 「聊天」 tab ---------- */
/* The chat tab's root: not .ptc, which is the corner pet (pets-life.css, hidden until shown). */
.ptc-tab { display: grid; gap: var(--gap); }
.ptc-tab > .section + .section, .ptc-tab > .card + .section, .ptc-tab > .section + .card, .ptc-tab > .card + .card { margin-top: 0; }
.ptc-tab .section-label { margin-top: 14px; }
/* 今天 / 本周 side by side: the app's .card + .card top margin must not push the second one down (§12). */
.ptc-usage > .card + .card { margin-top: 0; }
.ptc-skeleton { min-height: 120px; }
.ptc-notice { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; background: var(--accent-soft); box-shadow: none; padding: 14px 16px; }
.ptc-notice-icon { color: var(--accent); }
.ptc-notice-icon svg { width: 22px; height: 22px; }
.ptc-notice-text { font-size: 15px; line-height: 1.5; color: var(--text); }
.ptc-status { display: grid; gap: 10px; padding: 16px; }
.ptc-status-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: center; }
.ptc-status-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--positive-soft); color: var(--positive-text); }
.ptc-status[data-ok="false"] .ptc-status-icon { background: var(--surface-3); color: var(--text-2); }
.ptc-status-icon svg { width: 22px; height: 22px; }
.ptc-status-title { font-size: 16px; line-height: 1.4; }
.ptc-facts { display: grid; gap: 4px; padding-left: 46px; font-size: 14px; line-height: 1.45; color: var(--text-2); }

.ptc-alerts, .ptc-days { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
.ptc-alerts > .card + .card, .ptc-days > .card + .card { margin-top: 0; }
.ptc-alert { display: grid; gap: 10px; padding: 16px; }
.ptc-alert.is-focus { box-shadow: 0 0 0 3px var(--ptc-focus), var(--shadow-2); }
.ptc-alert-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "icon label level" "icon time time"; column-gap: 10px; row-gap: 2px; align-items: center; }
.ptc-alert-icon { grid-area: icon; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; }
.ptc-alert-icon svg { width: 22px; height: 22px; }
.ptc-alert-icon--urgent { background: var(--ptc-urgent-soft); color: var(--ptc-urgent); }
.ptc-alert-icon--watch { background: var(--ptc-watch-soft); color: var(--ptc-watch); }
.ptc-alert-label { grid-area: label; font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptc-alert-time { grid-area: time; font-size: 13px; color: var(--text-3); }
.ptc-level { grid-area: level; padding: 2px 10px; border-radius: var(--r-pill); font-size: 13px; font-weight: 700; }
.ptc-level--urgent { background: var(--ptc-urgent-soft); color: var(--ptc-urgent); }
.ptc-level--watch { background: var(--ptc-watch-soft); color: var(--ptc-watch); }
.ptc-alert-text { font-size: 15px; line-height: 1.55; }
.ptc-alert-delivery { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.ptc-alert-delivery svg { width: 16px; height: 16px; flex-shrink: 0; }
.ptc-alert-delivery--bad { color: var(--danger); font-weight: 600; }
.ptc-alert-follow { font-size: 13px; color: var(--text-2); padding-left: 10px; border-left: 3px solid var(--line-strong); }
.ptc-alert-done { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--positive-text); }
.ptc-alert-done svg { width: 16px; height: 16px; }
.ptc-question { display: grid; gap: 8px; padding-top: 10px; border-top: 1px dashed var(--line-strong); }
.ptc-question-text { font-size: 14px; font-weight: 600; }
.ptc-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: stretch; }
.ptc-pair-btn { width: 100%; height: 100%; min-height: 44px; }
.ptc-undelivered { display: flex; align-items: center; gap: 8px; margin-bottom: var(--gap); padding: 12px 14px; border-radius: var(--r-s); background: var(--danger-soft); color: var(--danger); font-size: 14px; font-weight: 600; }
.ptc-undelivered svg { width: 18px; height: 18px; flex-shrink: 0; }
.ptc-empty { padding: 16px; }

.ptc-days { grid-auto-rows: 1fr; }
.ptc-day { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 8px; height: 100%; padding: 16px; }
.ptc-day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ptc-day-date { font-size: 16px; }
.ptc-day-minutes { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.ptc-moods { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; }
.ptc-mood { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px; border-radius: var(--r-pill); background: var(--surface-2); font-size: 13px; color: var(--text-2); }
.ptc-mood svg { width: 16px; height: 16px; }
.ptc-mood--sad, .ptc-mood--scared, .ptc-mood--angry { background: var(--ptc-watch-soft); color: var(--ptc-watch); }
.ptc-day-text { font-size: 15px; line-height: 1.55; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.ptc-day-foot { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ptc-section:not(.ptc-bottom) > :not(.section-label) + :not(.section-label) { margin-top: var(--gap); }
.ptc-row--stack { flex-direction: column; align-items: stretch; gap: 10px; padding-top: 12px; padding-bottom: 12px; }
.ptc-row .row-title { white-space: normal; }
.ptc-seg { width: 100%; }
.ptc-minutes { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.ptc-minutes .seg-item { min-width: 0; }
.ptc-time { width: 150px; min-height: 44px; font-size: 16px; text-align: center; }
.ptc-tag { flex-shrink: 0; padding: 3px 10px; border-radius: var(--r-pill); font-size: 13px; font-weight: 700; white-space: nowrap; }
.ptc-tag--on { background: var(--positive-soft); color: var(--positive-text); }
.ptc-tag--off { background: var(--warning-soft); color: var(--warning-text); }
.ptc-tag--stale { background: var(--danger-soft); color: var(--danger); }
.ptc-push-test-row { padding: 12px 16px 16px; }
.ptc-push-test svg { width: 18px; height: 18px; }

.ptc-money { display: grid; gap: 14px; padding: 16px; }
.ptc-spend { display: grid; gap: 6px; }
.ptc-spend-head { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; }
.ptc-spend-who { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptc-spend-money { font-size: 14px; color: var(--text-2); }
.ptc-bar { display: block; height: 10px; border-radius: var(--r-pill); background: var(--ptc-bar-bg); overflow: hidden; }
.ptc-bar-fill { display: block; width: 100%; height: 100%; border-radius: inherit; background: var(--ptc-bar); transform-origin: left center; transform: scaleX(var(--ptc-fill, 0.02)); }
.ptc-spend[data-mode="saving"] .ptc-bar-fill { background: var(--ptc-bar-saving); }
.ptc-spend[data-mode="paused"] .ptc-bar-fill { background: var(--ptc-bar-paused); }
.ptc-money-note { line-height: 1.5; }
.ptc-bottom { display: grid; gap: 10px; margin-top: 8px; }
.ptc-privacy { line-height: 1.5; }
.ptc-delete svg { width: 18px; height: 18px; }
.ptc-hint { line-height: 1.5; }

/* ---------- the standalone preview host (until the pet room exists) ---------- */
.ptd-room {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: calc(var(--safe-top) + 14px) calc(var(--safe-right) + 18px) calc(var(--safe-bottom) + 18px) calc(var(--safe-left) + 18px);
  background: linear-gradient(180deg, var(--ptd-wall-1) 0%, var(--ptd-wall-2) 63.5%, var(--ptd-floor-1) 66%, var(--ptd-floor-2) 100%);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}
.ptd-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; }
.ptd-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 18px; border-radius: var(--r-pill); background: var(--ptk-glass); box-shadow: var(--ptk-shadow); font-size: 17px; font-weight: 700; color: var(--ptk-ink); text-decoration: none; }
.ptd-chip svg { width: 20px; height: 20px; }
.ptd-scene { position: relative; display: grid; place-items: center; min-height: 0; }
.ptd-pet { width: min(62vmin, 460px); aspect-ratio: 1; transition: transform var(--dur-3) var(--ease-out); }
.ptd-room.is-talking .ptd-pet { transform: translateY(-8%) scale(1.12); }
.ptd-pet-body { width: 100%; height: 100%; transform-origin: 50% 90%; transition: transform 140ms linear; }
.ptd-pet svg { width: 100%; height: 100%; overflow: visible; }
.ptd-pet-fill { fill: var(--ptd-cat); }
.ptd-pet-light { fill: var(--ptd-cat-light); }
.ptd-pet[data-species="dog"] .ptd-pet-fill { fill: var(--ptd-dog); }
.ptd-pet[data-species="dog"] .ptd-ear { fill: var(--ptd-dog-ear); }
.ptd-pet[data-species="cat"] .ptd-ear-dog, .ptd-pet[data-species="dog"] .ptd-ear-cat { display: none; }
.ptd-face { fill: var(--ptd-face-ink); }
.ptd-cheek { fill: var(--ptd-cheek); }
.ptd-pet-pose { position: absolute; left: 50%; top: 0; transform: translateX(-50%); padding: 4px 12px; border-radius: var(--r-pill); background: var(--ptk-glass); font-size: 13px; font-weight: 700; color: var(--text-2); }
.ptd-pet[data-pose="think"] .ptd-pet-body { transform: rotate(-6deg); }
.ptd-pet[data-pose="comfort"] .ptd-pet-body { transform: translateY(3%) rotate(2deg); }
.ptd-pet[data-pose="happy"] .ptd-pet-body, .ptd-pet[data-pose="laugh"] .ptd-pet-body, .ptd-pet[data-pose="proud"] .ptd-pet-body { transform: translateY(-3%); }
.ptd-actions { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-areas: "talk talk talk talk talk" "a b c d e"; gap: 14px; align-items: stretch; }
.ptd-actions > .ptk-entry { grid-area: talk; }
.ptd-act { display: grid; justify-items: center; align-content: center; gap: 4px; min-height: 96px; border: 0; border-radius: var(--r-l); background: var(--ptk-glass); box-shadow: var(--ptk-shadow); font-size: 16px; font-weight: 700; color: var(--text-2); }
.ptd-act svg { width: 30px; height: 30px; }
.ptd-room.is-talking .ptd-actions, .ptd-room.is-talking .ptd-top > :last-child { visibility: hidden; }
.ptd-adult { position: absolute; right: 0; bottom: 0; display: grid; gap: 10px; width: min(300px, 100%); padding: 16px; border-radius: var(--r-l); background: var(--ptk-glass); box-shadow: var(--ptk-shadow); }
.ptd-adult.is-first { right: 50%; top: 8%; bottom: auto; transform: translateX(50%); }
.ptd-adult-text { font-size: 16px; font-weight: 600; line-height: 1.45; }
.ptd-say { position: absolute; left: 50%; top: 6%; transform: translateX(-50%); max-width: min(90%, 560px); padding: 10px 18px; border-radius: var(--r-l); background: var(--ptk-glass); box-shadow: var(--ptk-shadow); font-size: 19px; font-weight: 600; line-height: 1.45; text-align: center; }
.ptd-demo { position: absolute; top: calc(var(--safe-top) + 76px); left: calc(var(--safe-left) + 18px); z-index: 6; display: grid; gap: 6px; width: 180px; padding: 10px; border-radius: var(--r-m); background: var(--ptk-glass); box-shadow: var(--ptk-shadow); font-size: 13px; }
.ptd-demo-title { font-weight: 700; color: var(--text-2); }
.ptd-demo select { min-height: 36px; font-size: 14px; }
.ptd-parent-switch { margin-bottom: var(--gap); }

/* Landscape is short: the grey heard line keeps to one line, so the words block stays within ~135px (two lines of
   heard words and a three-line caption reached 155px and covered the pet at 1024×768). */
@media (orientation: landscape) {
  .ptk-heard { -webkit-line-clamp: 1; }
}
@media (orientation: landscape) and (min-width: 900px) {
  .ptd-actions { grid-template-columns: repeat(5, minmax(0, 1fr)) auto; grid-template-areas: "a b c d e talk"; }
  .ptd-actions .ptk-entry-label { display: none; } /* landscape: a round button as tall as the others */
  .ptd-room.is-talking .ptd-scene { align-items: start; }
  .ptd-room.is-talking .ptd-pet { width: min(44vmin, 400px); transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ptk-caption { animation: none; }
  .ptk[data-state="thinking"] .ptk-mic { animation: none; }
  .ptk[data-armed="true"][data-state="ready"] .ptk-halo { animation: none; }
  .ptk-mic.is-busy { animation: none; }
  .ptk-ring-left, .ptk-halo, .ptd-pet, .ptd-pet-body { transition: none; }
}

/* The real room lends its stage to chat; the words, microphone and exit reserve their own space. */
.pt-room.is-talking { grid-template-areas: "scene"; grid-template-rows: minmax(0, 1fr); padding: var(--ptk-host-pad); }
.pt-room.is-talking > .pt-top,
.pt-room.is-talking > .pt-meters,
.pt-room.is-talking > .pt-actions,
.pt-room.is-talking .pt-scene > :not(.pt-petbox) { display: none; }
.pt-room > .ptk { position: absolute; }
.pt-room.is-talking .pt-petbox { top: var(--ptk-host-top); bottom: var(--ptk-host-bottom); pointer-events: none; }
.pt-room.is-talking .pt-stage { transform: none; }
.pt-stage.is-calm .pt-breath { animation: none; }
.pt-actions > .ptk-entry { justify-self: center; }
.pts-slot .pts-btn { width: 100%; height: 100%; }
@media (orientation: landscape) and (min-width: 900px) {
  .pt-actions:has(> .ptk-entry:not([hidden])) { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .pt-actions > .ptk-entry { grid-column: 2; grid-row: 1; }
  .pt-actions > .pt-acts { grid-column: 1; grid-row: 1; }
  .pt-actions > .pt-quiet { grid-column: 1 / -1; grid-row: 2; }
}

.pt-stage.is-calm .pt-fx { visibility: hidden; }
.ptc-usage { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; grid-auto-rows: 1fr; gap: var(--gap); }
.ptc-usage-cell { display: grid; align-content: center; gap: var(--gap); height: 100%; min-width: 0; padding: var(--card-pad); }
.ptc-usage-cell > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Parent review: shared dimensions; sensitive text wraps without widening its sheet. */
.ptc-history, .ptc-history-messages, .ptc-message { display: grid; gap: var(--gap); min-width: var(--zero); }
.ptc-history-days { display: grid; align-items: stretch; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: var(--gap); }
.ptc-history-day { display: grid; height: var(--full); white-space: normal; min-width: var(--zero); }
.ptc-history-day strong, .ptc-history-day span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptc-message-text { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.ptc-message--flagged { background: var(--warning-soft); border-color: var(--warning); }
.ptc-quality-label { color: var(--text); font-weight: var(--weight-semibold); }
.ptc-recap-tabs { width: var(--full); }
.ptc-recap-body { margin-top: var(--gap); }
