:root {
  color-scheme: light;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #263b33;
  background: #e6ece8;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  --paper: #f8f9f4;
  --card: #fdfdf8;
  --ink: #263b33;
  --muted: #566b60;
  --line: #d9e2d8;
  --accent: #436957;
  --accent-soft: #deeade;
  --accent-ink: #2c5542;
  --avatar-bg: #d4e2ce;
  --avatar-ink: #365746;
  --shell-width: 452px;
  --shell-height: 100vh;
  --shell-height: var(--app-height, 100dvh);
  --frame-top: 0px;
  --frame-left: max(0px, calc((100vw - var(--shell-width)) / 2));
  --frame-inset: 0px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden], dialog:not([open]) { display: none !important; }
html, body { margin: 0; min-width: 0; }
html { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: radial-gradient(ellipse at 18% 18%, #f3f4ed, transparent 56%),
              radial-gradient(ellipse at 88% 80%, #d5dfd6, transparent 66%), #e6ece8;
}
button, input, textarea { font: inherit; color: inherit; }
button {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 2px solid #456e58;
  outline-offset: 3px;
}
button:disabled { opacity: .52; cursor: default; }
button svg, [data-icon] > svg { width: 23px; height: 23px; display: block; flex: none; }
h1, h2, p { margin: 0; }
img { display: block; max-width: 100%; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

.phone-shell {
  position: fixed;
  top: calc(var(--viewport-top, 0px) + var(--frame-top));
  left: 0;
  right: 0;
  isolation: isolate;
  container: phone / size;
  width: min(100%, var(--shell-width));
  height: var(--shell-height);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow: clip;
  background: var(--paper);
}
.phone-shell[data-role="v"] { --accent: #7b6249; --accent-soft: #f0e6d6; --accent-ink: #694e36; }
.phone-shell[data-role="aven"] { --accent: #716183; --accent-soft: #eae4f0; --accent-ink: #5d4d70; }
.phone-shell[data-role="v"], .role-choice[data-role="v"], .avatar[data-role="v"] { --avatar-bg: #e9dabf; --avatar-ink: #6c503a; }
.phone-shell[data-role="aven"], .role-choice[data-role="aven"], .avatar[data-role="aven"] { --avatar-bg: #e4ddec; --avatar-ink: #655575; }
.phone-shell[data-role="swan"], .role-choice[data-role="swan"], .avatar[data-role="swan"] { --avatar-bg: #d4e2ce; --avatar-ink: #365746; }
.topbar {
  flex: none;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid #dce4da;
  background: #f8faf5;
  z-index: 1;
}
.icon-button { display: grid; place-items: center; border-radius: 50%; color: #395044; }
.current-role {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 2px 8px;
  text-align: left;
  border-radius: 22px;
}
.current-role strong, .current-role small, .role-choice-copy strong, .role-choice-copy small { display: block; }
.current-role strong { font-size: 16px; font-weight: 650; letter-spacing: .01em; line-height: 1.2; }
.current-role small { color: var(--muted); font-size: 12px; letter-spacing: .08em; line-height: 1.6; }
.mini-chevron { margin-left: 2px; color: #687c6e; font-size: 16px; }
.avatar, .scene-monogram {
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  flex: none;
  border-radius: 50%;
  background: var(--avatar-bg) center / cover;
  color: var(--avatar-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
}
.avatar { width: 44px; height: 44px; font-size: 24px; }
.avatar-small { width: 35px; height: 35px; font-size: 21px; }
.avatar img, .scene-monogram img { width: 100%; height: 100%; object-fit: cover; }
#main { flex: 1 1 0; min-height: 0; min-width: 0; overflow: hidden; overflow: clip; }
.view {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 25px max(21px, env(safe-area-inset-right, 0px)) 24px max(21px, env(safe-area-inset-left, 0px));
  scrollbar-width: thin;
  scrollbar-color: #c4d1c3 transparent;
}
.home-indicator { flex: none; height: calc(13px + env(safe-area-inset-bottom, 0px)); display: grid; justify-items: center; background: var(--paper); }
.home-indicator::before { content: ""; width: 64px; height: 3px; border-radius: 3px; background: #a8b6aa; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1.3; letter-spacing: .16em; }
.prototype-note, .fine-print { color: var(--muted); font-size: 12px; line-height: 1.65; }
.prototype-note { text-align: center; }

/* The open window, long shadow and ceramic vase belong to this small room. */
.home-view {
  display: flex;
  flex-direction: column;
  background: linear-gradient(164deg, #f7f9f1 0%, #f4f7ef 49%, var(--paper) 94%);
}
.home-view > * { flex-shrink: 0; }
.home-clock { text-align: center; padding: clamp(5px, 2vh, 19px) 0 clamp(19px, 3.5vh, 34px); }
.home-clock p { min-height: 18px; color: #526b5a; font-size: 12px; font-weight: 600; letter-spacing: .09em; }
#clockTime, .timer-display {
  font-family: Georgia, "Times New Roman", serif;
  font-variant-numeric: lining-nums tabular-nums;
  font-weight: 400;
  letter-spacing: -.055em;
  line-height: 1.07;
}
#clockTime { margin: 2px 0 5px; color: #324f3f; font-size: clamp(55px, 10vh, 78px); }
.home-clock > span { color: #627464; font-size: 12px; letter-spacing: .13em; }
.scene-card {
  position: relative;
  isolation: isolate;
  display: block;
  width: 100%;
  height: clamp(188px, 29vh, 258px);
  overflow: hidden;
  text-align: left;
  border: 1px solid #c3d3bf;
  border-radius: 23px;
  background: #d6e2cc;
  box-shadow: 0 8px 18px -14px #44604d;
}
.scene-topline, .scene-caption { position: absolute; left: 17px; right: 17px; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.scene-topline { top: 14px; }
.scene-topline .eyebrow { color: #3d5c49; font-size: 9px; }
.scene-state { padding: 3px 8px; border: 1px solid #aec4ac; border-radius: 11px; background: #eef4e8; color: #47634d; font-size: 12px; font-weight: 600; }
.room-art { position: absolute; inset: 0; overflow: hidden; background: linear-gradient(104deg, #e4ecda, #d2e0c7 66%, #c1d2b9); }
.room-art::before { content: ""; position: absolute; inset: 24% 10% 7% 8%; background: linear-gradient(125deg, #fff2c9, #f8eac930); clip-path: polygon(26% 0, 52% 0, 96% 100%, 50% 100%); opacity: .76; }
.window-frame {
  position: absolute;
  left: 16%; top: 17%; width: 32%; height: 50%;
  overflow: hidden;
  border: 5px solid #a5bba6;
  border-radius: 60% 60% 2px 2px / 63% 63% 2px 2px;
  background: radial-gradient(circle at 73% 43%, #fff5c8 0 10%, transparent 11%), linear-gradient(160deg, #bdd6c9, #e3ead7 57%, #f7ecd0);
  box-shadow: -4px 2px 0 #f2efda, 6px 5px 0 #78978036;
}
.window-frame::before, .window-frame::after { content: ""; position: absolute; background: #a4b6a0; }
.window-frame::before { inset: 0 auto 0 48%; width: 3px; }
.window-frame::after { top: 54%; left: 0; width: 100%; height: 3px; }
.sun-disc { position: absolute; right: 12%; top: 22%; width: 27%; aspect-ratio: 1; border: 1px solid #bfceb3; border-radius: 50%; }
.room-floor { position: absolute; left: 0; right: 0; bottom: 0; height: 36%; background: linear-gradient(163deg, #c3d2b8 0 30%, #d7dfc6 30% 45%, #c7d3bb 45% 63%, #d0dac2 63%); }
.room-floor::after { content: ""; position: absolute; inset: 40% 0 0; background: linear-gradient(transparent, #c8d6be); }
.room-vase { position: absolute; left: 5%; bottom: 33%; width: 23px; height: 28px; background: linear-gradient(90deg,#b8a78e,#deceb4 64%,#b5a58c); border-radius: 38% 34% 45% 45%; transform: rotate(-4deg); }
.room-vase::before, .room-vase::after { content: ""; position: absolute; bottom: 89%; width: 11px; height: 29px; border-radius: 100% 0 100% 0; background: #809a7d; }
.room-vase::before { left: 4px; transform: rotate(-34deg); }
.room-vase::after { left: 12px; height: 23px; background: #95ad88; transform: rotate(13deg); }
.scene-monogram { position: absolute; top: 30%; right: 17%; width: clamp(49px, 8vh, 72px); aspect-ratio: 1; font-size: clamp(32px, 6vh, 48px); border: 3px solid #f4f4e3; box-shadow: 0 7px 14px #4054421a; }
.scene-sparkle { position: absolute; right: 10%; top: 36%; font: 24px/1 Georgia, serif; color: #fbf6dc; }
.scene-caption { align-items: flex-end; bottom: 13px; }
.scene-caption small, .scene-caption strong { display: block; }
.scene-caption small { color: #456049; font-size: 12px; letter-spacing: .09em; }
.scene-caption strong { margin-top: 2px; color: #2b4735; font-size: clamp(19px, 5vw, 25px); letter-spacing: -.03em; font-weight: 640; }
.scene-chat-icon { display: grid; place-items: center; width: 37px; height: 37px; border: 1px solid #f4f7e5; border-radius: 50%; background: #e7efdc; color: #42634d; }
.scene-chat-icon svg { width: 18px; height: 18px; }
.app-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 24px 0; }
.app-icon { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border-radius: 13px; font-size: 13px; font-weight: 560; }
.app-tile { width: clamp(47px, 13vw, 58px); aspect-ratio: 1; display: grid; place-items: center; border: 1px solid #ffffffab; border-radius: 30%; box-shadow: 0 2px 4px #53634f14; }
.app-tile svg { width: 26px; height: 26px; }
.tile-chat { background: #cddfce; color: #3f6550; }
.tile-accompany { background: #e3dfee; color: #746483; }
.tile-memory { background: #ebdfcc; color: #806950; }
.tile-settings { background: #dce6e3; color: #496963; }
.home-note { display: flex; justify-content: center; align-items: center; gap: 7px; padding: 8px 0; margin-top: auto; color: #5d6d5e; font-size: 13px; }
.tiny-star { color: #778a71; font: 18px Georgia, serif; }
.home-view .prototype-note { margin-top: 3px; font-size: 12px; letter-spacing: .06em; }

.section-heading, .sheet-heading, .sidebar-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-heading { margin-bottom: 15px; }
.section-heading h1, .sheet-heading h2, .sheet-dialog > h2, .sidebar-dialog h2 { font-size: clamp(23px, 6vw, 29px); line-height: 1.3; letter-spacing: -.045em; }
.section-heading h1, .sheet-heading h2 { margin-top: 4px; }
.page-intro { margin: 0 0 17px; color: var(--muted); font-size: 14px; line-height: 1.75; }
.text-button, .save-memory-button { color: var(--accent-ink); font-size: 13px; font-weight: 650; padding: 0 7px; border-radius: 9px; }
.section-heading .text-button { flex: none; }
.primary-button, .secondary-button { border-radius: 13px; padding: 9px 15px; font-size: 15px; font-weight: 650; }
.primary-button { background: var(--accent); color: #fff; }
.secondary-button { background: #edf2e9; color: #365343; border: 1px solid var(--line); }
.count-chip, .soon-badge { flex: none; padding: 4px 9px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; }
textarea { width: 100%; resize: vertical; min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fffef9; line-height: 1.55; font-size: 16px; }
textarea::placeholder { color: #68786c; opacity: 1; }
.chat-view { display: flex; flex-direction: column; gap: 8px; overflow: hidden; overflow: clip; padding-bottom: 7px; }
.chat-view > :not(.message-list) { flex-shrink: 0; }
.chat-view .section-heading { margin-bottom: 0; }
.demo-notice { padding: 7px 10px; border-left: 2px solid #aaba9f; background: #eef2e8; color: #52624f; font-size: 12px; }
.message-list { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; gap: 12px; padding: 8px 3px 8px 0; scrollbar-width: thin; }
.message { display: flex; flex: none; flex-direction: column; align-items: flex-start; min-width: 0; }
.message.user { align-items: flex-end; }
.message-bubble { max-width: 88%; border: 1px solid #dce3d7; padding: 9px 13px; border-radius: 15px 15px 15px 4px; background: #fffef9; color: var(--ink); font-size: 15px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user .message-bubble { border-color: var(--accent-soft); border-radius: 15px 15px 4px 15px; background: var(--accent-soft); color: var(--accent-ink); }
.message.event { align-items: center; }
.message.event .message-bubble { max-width: 94%; border-color: transparent; border-radius: 12px; background: #ebefe6; color: #526657; font-size: 13px; }
.message-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 2px; color: var(--muted); font-size: 12px; }
.save-memory-button { font-size: 14px; }
.quick-prompts { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-prompts button, .timer-options button { border: 1px solid var(--line); border-radius: 16px; padding: 6px 11px; background: #f4f6ef; color: #415a49; font-size: 13px; }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 4px; border: 1px solid #cbd8cb; border-radius: 18px; background: #fffef9; }
.composer textarea { flex: 1 1 0; height: 48px; max-height: 104px; resize: none; overflow-y: auto; border-color: transparent; background: transparent; padding: 9px 7px; }
.composer textarea:focus-visible { outline-offset: -2px; }
.send-button { display: grid; place-items: center; flex: none; border-radius: 13px; background: var(--accent); color: white; }
.send-button svg { width: 19px; height: 19px; }
.empty-state { display: grid; justify-items: center; gap: 6px; margin: auto 0; padding: 20px 12px; text-align: center; color: var(--muted); }
.empty-symbol { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-size: 23px; }
.empty-state h2 { color: var(--ink); font-size: 16px; }
.empty-state p { max-width: 29em; font-size: 13px; }
.memory-form, .memory-card, .soft-card, .settings-group { border: 1px solid var(--line); border-radius: 17px; background: var(--card); }
.memory-form { display: grid; gap: 9px; padding: 15px; }
.memory-form label, .soft-card strong, .settings-info strong, .settings-row strong { font-size: 15px; font-weight: 650; }
.memory-form textarea { min-height: 72px; }
.memory-form .primary-button { justify-self: end; }
.memory-list { display: grid; gap: 10px; margin-top: 16px; }
.memory-card { padding: 13px 15px 4px; }
.memory-date { color: var(--muted); font-size: 12px; }
.memory-text { margin-top: 5px; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.memory-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.focus-card { padding: 25px 15px 19px; border: 1px solid #d0ddca; border-radius: 23px; background: radial-gradient(ellipse at 80% 5%,#fff9dd88,transparent 46%), linear-gradient(145deg,#e9efdf,#dce8d8); text-align: center; }
.focus-label { display: block; color: #52694e; font-size: 13px; letter-spacing: .06em; }
.timer-display { margin: 13px 0 17px; color: #385343; font-size: clamp(58px, 14vw, 83px); }
.timer-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0 0 16px; }
.timer-options button { min-width: 60px; background: #f6f8ef; }
.timer-options button.selected, .timer-options button[aria-pressed="true"] { background: #425f49; border-color: #425f49; color: white; }
.focus-card .primary-button { min-width: 130px; }
.focus-card .fine-print { margin-top: 13px; }
.soft-card { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 14px; }
.soft-card > div { flex: 1; min-width: 0; }
.soft-card p, .settings-info p, .settings-row small { color: var(--muted); font-size: 13px; line-height: 1.65; }
.small-icon { width: 39px; height: 39px; flex: none; display: grid; place-items: center; border-radius: 11px; color: #6d5a7b; background: #e8e0ed; }
.settings-group { margin: 0 0 13px; padding: 5px 14px; }
.settings-group h2 { margin: 9px 0 4px; color: var(--muted); font-size: 12px; letter-spacing: .06em; }
.settings-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 0; }
.settings-row + .settings-row { border-top: 1px solid var(--line); }
.settings-row strong, .settings-row small { display: block; }
.settings-row > span:last-child { color: #677d6b; }
.settings-info { padding: 7px 0 9px; }
.settings-info p { margin-top: 6px; }

dialog {
  position: fixed;
  max-width: none;
  max-height: none;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 18px 56px #27382c29;
  overscroll-behavior: contain;
}
dialog::backdrop { background: #26382c50; }
.sheet-dialog {
  inset: auto auto max(0px, calc(var(--viewport-bottom, 0px) + var(--app-height, 100dvh) - var(--shell-height) - var(--frame-top) + var(--frame-inset))) 50%;
  transform: translateX(-50%);
  width: min(100%, calc(var(--shell-width) - 2 * var(--frame-inset)));
  max-height: calc(var(--shell-height) - 14px);
  overflow-y: auto;
  padding: 22px 19px calc(20px + env(safe-area-inset-bottom, 0px));
  border-radius: 23px 23px 0 0;
}
.sheet-heading { margin-bottom: 12px; }
.sheet-dialog > .page-intro { margin: 9px 0 15px; overflow-wrap: anywhere; }
.sheet-dialog .fine-print { margin-top: 13px; }
.role-choices { display: grid; gap: 7px; }
.role-choice { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: 14px; text-align: left; background: #fdfdf8; }
.role-choice.selected, .role-choice[aria-pressed="true"] { border-color: #94ad98; background: #eaf0e6; }
.role-choice-copy { flex: 1; min-width: 0; }
.role-choice-copy strong, .section-heading h1, .scene-caption strong { overflow-wrap: anywhere; }
.current-role > span:nth-child(2) { min-width: 0; }
.current-role strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-choice-copy small { color: var(--muted); font-size: 12px; }
.role-check { margin-left: auto; color: #48664c; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.dialog-actions button { flex: 1 1 100px; }
#restoreSummary { margin: 12px 0; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.sidebar-dialog {
  inset: calc(var(--viewport-top, 0px) + var(--frame-top) + var(--frame-inset)) auto auto calc(var(--frame-left) + var(--frame-inset));
  width: min(295px, calc(100% - 42px));
  height: calc(var(--shell-height) - 2 * var(--frame-inset));
  padding: calc(15px + env(safe-area-inset-top, 0px)) 19px calc(20px + env(safe-area-inset-bottom, 0px));
  border-radius: 0 24px 24px 0;
  overflow-y: auto;
}
.sidebar-dialog[open] { display: flex; flex-direction: column; }
.sidebar-heading { margin-bottom: 23px; }
.brand-mark { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 50%; background: #dce8d7; color: #4e6b53; font: 27px Georgia, serif; }
.sidebar-dialog h2 { margin: 6px 0; }
.sidebar-caption, .sidebar-bottom { color: var(--muted); font-size: 13px; }
.sidebar-nav { display: grid; gap: 3px; margin: 18px 0; }
.sidebar-nav button { display: flex; align-items: center; gap: 13px; text-align: left; padding: 8px 10px; border-radius: 11px; }
.sidebar-nav button[aria-current="page"], .sidebar-nav button.selected, .sidebar-nav button.active { background: #e1ebdc; color: #31553c; }
.sidebar-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.sidebar-bottom p { font-size: 12px; }
.save-warning { flex: none; padding: 6px 12px; background: #fff0d4; color: #684913; font-size: 12px; text-align: center; }
.toast {
  position: fixed; z-index: 5; left: 50%; bottom: max(24px, calc(var(--viewport-bottom, 0px) + var(--app-height, 100dvh) - var(--shell-height) - var(--frame-top) + 24px));
  transform: translateX(-50%); max-width: min(85%, 380px); padding: 10px 15px;
  border-radius: 13px; color: #fff; background: #33493d; box-shadow: 0 5px 15px #23382921; text-align: center; font-size: 14px; overflow-wrap: anywhere;
}
@media (hover: hover) {
  .icon-button:hover, .sidebar-nav button:hover, .settings-row:hover, .text-button:hover, .save-memory-button:hover { background: #e6ede1; }
  .app-icon:hover .app-tile { box-shadow: 0 3px 8px #43594330; }
  .scene-card:hover, .primary-button:hover, .send-button:hover { filter: brightness(.98); }
}
@media (min-width: 540px) and (min-height: 520px) {
  :root { --shell-height: min(860px, calc(var(--app-height, 100dvh) - 32px)); --frame-top: calc((var(--app-height, 100dvh) - var(--shell-height)) / 2); --frame-inset: 5px; }
  .phone-shell { border: var(--frame-inset) solid #fbfcf7; border-radius: 33px; box-shadow: 0 0 0 1px #cbd5c9, 0 16px 50px #415c4529; }
  .sidebar-dialog { border-radius: 28px 20px 20px 28px; }
  .sheet-dialog { border-radius: 22px 22px 28px 28px; }
}
@media (max-width: 350px) {
  .view { padding-left: max(13px, env(safe-area-inset-left, 0px)); padding-right: max(13px, env(safe-area-inset-right, 0px)); }
  .topbar { gap: 4px; }
  .scene-caption, .scene-topline { left: 13px; right: 13px; }
  .app-grid { gap: 3px; }
  .section-heading .text-button { padding: 0 3px; }
  .soft-card { gap: 7px; padding: 10px; }
}
@media (max-height: 570px) {
  .topbar { padding-top: max(1px, env(safe-area-inset-top, 0px)); padding-bottom: 1px; }
  .chat-view { padding-top: 5px; gap: 3px; }
  .chat-view .section-heading .eyebrow { display: none; }
  .chat-view .section-heading h1 { font-size: 20px; margin: 0; }
  .demo-notice { padding-top: 3px; padding-bottom: 3px; }
  .home-clock { padding-top: 0; }
  .sidebar-heading { margin-bottom: 6px; }
}
@container phone (max-height: 460px) {
  .topbar { padding-top: max(1px, env(safe-area-inset-top, 0px)); padding-bottom: 1px; }
  .chat-view { padding-top: 4px; gap: 3px; }
  .chat-view .section-heading .eyebrow, .chat-view .quick-prompts { display: none; }
  .chat-view .section-heading h1 { font-size: 19px; margin: 0; }
  .demo-notice { padding-top: 2px; padding-bottom: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}

.home-connection { align-self: center; padding: 0 9px; }
.chat-connection { min-height: 32px; text-align: left; overflow-wrap: anywhere; }
.connection-form { display: grid; gap: 7px; padding: 10px 14px 14px; }
.connection-form h2 { margin: 0 0 3px; }
.connection-form label { font-size: 14px; font-weight: 620; }
.connection-form input, .connection-form select {
  width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 10px; color: var(--ink); background: #fffef9; font: inherit;
}
.connection-form input:focus-visible, .connection-form select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.connection-form > button { justify-self: start; }
.connection-form .remember-key { display: flex; align-items: center; gap: 9px; min-height: 44px; cursor: pointer; }
.connection-form .remember-key input { width: 20px; min-width: 20px; height: 20px; min-height: 20px; margin: 0; padding: 0; accent-color: var(--accent); }
.connection-form .clear-saved-keys { padding: 8px 0; min-height: 44px; text-align: left; }
.connection-form .credential-warning { color: #8b3c21; font-size: 14px; }
#modelField, #customFields { display: grid; gap: 5px; }
#modelField label:not(:first-child) { margin-top: 4px; }
.form-hint { color: var(--muted); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.attachment-preview, .compose-tools { display: flex; align-items: center; gap: 6px; min-width: 0; }
.attachment-preview { padding: 4px 7px; border: 1px solid var(--line); border-radius: 12px; }
.attachment-preview > img { width: 46px; height: 46px; object-fit: cover; border-radius: 7px; }
.attachment-preview > div { flex: 1; }
.attachment-preview strong, .attachment-preview small { display: block; }
.attachment-preview strong { font-size: 13px; }
.attachment-preview small, .compose-tools small, .reply-feedback small { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.photo-tool { display: flex; align-items: center; justify-content: center; gap: 5px; padding: 0 6px; border-radius: 8px; font-size: 12px; }
.photo-tool svg { width: 17px; height: 17px; }
.compose-tools small { margin-left: auto; text-align: right; }
.stop-button { border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); padding: 0 8px; }
.chat-photo { max-width: min(100%, 260px); max-height: 220px; margin: 0 auto 3px; object-fit: contain; border-radius: 8px; }
.reply-feedback { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 5px; max-width: 96%; }
#createRoleForm { border: 0; background: none; padding: 16px 0 0; }
#newRole { width: 100%; margin-top: 9px; }
.avatar-dialog { max-height: calc(var(--app-height, 100dvh) - 24px); padding-bottom: max(18px, env(safe-area-inset-bottom, 0px)); }
.avatar-dialog .sheet-heading { margin-bottom: 8px; }
.avatar-dialog h2 { font-size: 24px; overflow-wrap: anywhere; }
.avatar-help { margin: 8px 0 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.avatar-crop-frame { width: min(100%, 270px, 37dvh); aspect-ratio: 1; margin: 0 auto 12px; border-radius: 50%; overflow: hidden; border: 2px solid var(--accent); background: #fff; }
#avatarCanvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; user-select: none; }
#avatarCanvas:active { cursor: grabbing; }
.avatar-controls { display: grid; gap: 4px; }
.avatar-controls > label { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 620; }
.avatar-controls output { font-variant-numeric: tabular-nums; color: var(--muted); }
.avatar-controls input[type="range"] { display: block; width: 100%; min-width: 0; min-height: 36px; margin: 0; accent-color: var(--accent); }
.avatar-position { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; font-size: 13px; color: var(--muted); }
.avatar-status { margin: 6px 0; min-height: 1.5em; font-size: 14px; line-height: 1.5; }
.avatar-actions { flex-wrap: wrap; gap: 7px; }
.avatar-actions button { flex: 1; padding-left: 10px; padding-right: 10px; white-space: nowrap; }
#editAvatar:disabled { opacity: .5; }
@container phone (max-height: 460px) {
  .chat-connection { min-height: 24px; }
  .attachment-preview > img { width: 36px; height: 36px; }
  .compose-tools { gap: 2px; }
  .chat-view { gap: 2px; }
  .chat-view .section-heading { display: none; }
  .chat-connection { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.phone-shell[data-keyboard="true"] .home-indicator { height: 4px; }
.phone-shell[data-keyboard="true"] .home-indicator::before { display: none; }
