#chatsPanel { min-height: calc(100dvh - 98px - var(--safe-bottom)); }
.chat-sheet.chat-camera-sheet { width: min(100%, 520px); max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0 auto; border: 0; border-radius: 0; background: #000; color: #fff; }
.chat-camera-sheet .chat-media-form { height: 100%; min-height: 0; padding: max(8px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); grid-template-rows: auto minmax(0, 1fr) auto; gap: 8px; }
.chat-camera-sheet .chat-media-form > header button { color: #fff; min-height: 44px; }
.chat-camera-sheet .chat-media-form > header button:last-child { text-align: right; }
.chat-camera-sheet.is-capturing [data-chat-photo-library] { visibility: hidden; }
.chat-camera-sheet .live-camera-heading { display: none; }
.chat-camera-sheet .chat-media-file-input[hidden], .chat-camera-sheet .chat-audio-file-input[hidden] { display: none; }
.chat-camera-sheet .chat-media-editor { min-height: 0; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.chat-camera-sheet.is-capturing .chat-media-editor { display: none; }
.chat-camera-sheet .chat-media-preview { flex: 1 1 280px; min-height: 160px; width: 100%; aspect-ratio: 3 / 4; border: 0; border-radius: 20px; background: #111; color: #fff; }
.chat-camera-sheet .chat-media-preview img, .chat-camera-sheet .chat-media-preview video { position: absolute; inset: 0; }
.chat-media-edit-options { flex: 0 0 auto; }
.chat-media-edit-options summary { min-height: 44px; display: flex; align-items: center; justify-content: center; border: 1px solid #666; border-radius: 999px; cursor: pointer; }
.chat-media-edit-options label { display: grid; gap: 6px; }
.chat-media-edit-options .camera-effect-picker { background: #17282b; color: #fff; border-color: #718184; }
.chat-media-edit-options .camera-effect-picker small { color: #ddd; }
.chat-camera-sheet .chat-media-overlay { width: 100%; background: #222; color: #fff; border-color: #777; }
.chat-camera-sheet .chat-media-option { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; min-height: 44px; }
.chat-camera-sheet .chat-media-option small, .chat-camera-sheet .chat-media-status { color: #ddd; }
.chat-camera-sheet .chat-media-option input { width: 20px; height: 20px; accent-color: #ffb15e; }
.chat-media-review-actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 12px; flex-shrink: 0; }
.chat-media-review-actions > button { min-height: 48px; margin: 0; display: flex; align-items: center; justify-content: center; gap: 8px; border: 2px solid #fff; border-radius: 999px; background: #222; color: #fff; }
.chat-media-review-actions .chat-media-publish { background: var(--peach); color: var(--on-peach); border-color: #000; }
.chat-media-sources { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chat-media-sources button { min-height: 44px; border: 0; padding: 4px 8px; background: transparent; color: #ddd; font-size: 12px; }
.live-camera[hidden] { display: none; }
.chat-sheet.is-capturing { width: min(100%, 520px); max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0 auto; border-radius: 0; background: #000; color: #fff; }
.is-capturing .memento-form { height: 100%; padding: 0; gap: 0; grid-template-rows: auto minmax(0, 1fr); }
.is-capturing .memento-form > :not(header):not(.live-camera) { display: none; }
.is-capturing .memento-form > header { padding: max(8px, env(safe-area-inset-top)) 16px 8px; background: #000; }
.is-capturing .memento-form > header button { color: #fff; min-height: 44px; }
.live-camera { min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto auto auto; padding: 0 0 max(16px, env(safe-area-inset-bottom)); background: #000; color: #fff; }
.live-camera-stage { position: relative; min-height: 0; height: min(100%, calc((100vw - 16px) * 4 / 3), 672px); aspect-ratio: 3 / 4; place-self: center; overflow: hidden; background: #111; border-radius: 24px; margin: 0 0 12px; }
.live-camera-stage video { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.live-camera-stage video.mirrored { transform: scaleX(-1); }
.live-camera-stage .live-camera-inset { position: absolute; width: 27%; aspect-ratio: 3 / 4; object-fit: cover; right: 16px; top: 16px; border: 2px solid #fff; border-radius: 12px; }
.live-camera-heading { position: absolute; left: 16px; right: 16px; top: 16px; display: grid; justify-items: center; gap: 4px; }
.live-camera-heading strong, .live-camera-heading span { padding: 5px 12px; border-radius: 12px; background: rgba(0,0,0,.65); }
.live-camera-heading strong { font-size: 20px; }
.live-camera-heading span { font: 600 13px system-ui, sans-serif; }
.live-camera-message:not(:empty) { position: absolute; inset: 40% 24px auto; padding: 20px; border-radius: 16px; background: rgba(0,0,0,.8); text-align: center; font: 500 16px/1.5 system-ui, sans-serif; }
.live-camera-controls { display: grid; grid-template-columns: 1fr 86px 1fr; align-items: center; justify-items: center; gap: 16px; }
.live-camera-controls button { min-width: 48px; height: 48px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: #242424; color: #fff; }
.live-camera-controls .camera-shutter { width: 78px; height: 78px; padding: 5px; border: 3px solid #fff; background: transparent; }
.camera-shutter span { width: 100%; height: 100%; background: #fff; border-radius: 50%; transition: transform .12s ease; }
.camera-shutter:active span { transform: scale(.88); }
.live-camera-controls button:disabled { opacity: .4; }
.live-camera-hint { margin: 12px 12px 0; text-align: center; font: 500 13px/1.4 system-ui, sans-serif; color: #ddd; }
.live-camera-alternatives { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.live-camera-alternatives button { min-height: 44px; padding: 8px 12px; border: 0; background: transparent; color: #fff; text-decoration: underline; }
.live-camera-alternatives button[hidden] { display: none; }
.memento-photo-fallback[hidden] { display: none; }
.memento-photo-fallback label { display: grid; gap: 12px; }
.live-camera-controls [data-camera-library][hidden] { visibility: hidden; }
.chat-sheet[data-memento-dialog]:not(.is-capturing) { height: min(820px, calc(100dvh - 24px)); overflow: hidden; }
.memento-form { height: 100%; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto auto auto; }
.memento-review-title { margin: 0; text-align: center; font-size: 24px; }
.memento-review-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 12px; }
.memento-review-actions > button { min-height: 54px; height: auto; margin: 0; padding: 10px; border: 2px solid var(--outline); border-radius: 18px; font-size: .95rem; overflow-wrap: anywhere; }
.memento-review-actions .memento-retake { background: var(--white); color: var(--ink); }
.memento-send-feedback { display: grid; gap: 8px; }
.memento-send-feedback .memento-status { margin: 0; overflow-wrap: anywhere; }
.chat-sheet:not(.is-capturing) .memento-skip { display: none; }
.memento-review-content { min-height: 0; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 13px; padding: 2px; }
.memento-review-content > * { flex-shrink: 0; }
.memento-review-content > label { display: grid; gap: 5px; font-size: .85rem; }
.memento-review-content .memento-preview { width: min(100%, 290px); align-self: center; }
.memento-retake { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border: 0; background: transparent; }
.memento-preview > .ui-icon { width: 48px; height: 48px; }
.chat-empty > span > .ui-icon { width: 48px; height: 48px; }
.chat-shell { width: min(100%, 650px); margin: 0 auto; }
.chat-page-header, .chat-room-header { min-height: 58px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 2px 2px 12px; }
.chat-page-header p, .chat-page-header h1 { margin: 0; }
.chat-page-header p { color: var(--muted); font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; }
.chat-page-header h1 { font-size: 28px; line-height: 1.2; text-align: center; }
.chat-page-header { grid-template-columns: 44px minmax(0, 1fr) 44px; padding: 0 0 8px; }
.chat-page-header .chat-icon-button { border: 0; background: transparent; color: var(--dark-teal); border-radius: 12px; }
.chat-icon-button { min-width: 44px; height: 44px; padding: 0 10px; border: 2px solid var(--outline); border-radius: 50%; background: var(--white); font-size: 1.55rem; line-height: 1; }
.chat-list-status, .chat-room-status, .chat-create-status { min-height: 1.35em; color: var(--muted); font-size: .83rem; text-align: center; }
.chat-search-form { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; margin: 8px 0; }
.chat-search-form label { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; min-height: 44px; padding: 0 11px; border: 1px solid var(--outline); border-radius: 14px; background: var(--white); }
.chat-search-form input { min-width: 0; border: 0; outline: 0; background: transparent; color: inherit; font: inherit; font-size: 16px; }
.chat-search-form button { min-height: 44px; padding: 0 14px; border: 0; border-radius: 14px; background: var(--ink); color: var(--white); font-weight: 800; }
.chat-search-results { display: grid; gap: 12px; padding: 8px 0 24px; }
.chat-search-results section { display: grid; gap: 7px; }
.chat-search-results h2 { margin: 4px 2px; color: var(--muted); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; }
.chat-search-results button { display: grid; gap: 3px; width: 100%; padding: 12px 14px; border: 1px solid var(--outline); border-radius: 14px; background: var(--white); color: inherit; text-align: left; }
.chat-search-results small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.chat-list { display: grid; gap: 11px; }
.chat-row { overflow: hidden; border: 3px solid var(--outline); border-radius: 12px; background: var(--white); box-shadow: 0 2px 4px rgba(5,9,20,.1); content-visibility: auto; contain-intrinsic-size: auto 82px; }
.chat-row.attention { background: color-mix(in srgb, #ffb15e 22%, var(--white)); }
.chat-row-main { width: 100%; min-height: 76px; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 10px 12px; border: 0; background: transparent; text-align: left; }
.chat-avatar { width: 52px; height: 52px; display: grid; place-items: center; overflow: hidden; border: 2px solid var(--outline); border-radius: 50%; background: var(--peach); color: var(--on-peach); font-size: 1.3rem; }
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-row-copy { min-width: 0; display: grid; gap: 5px; }
.chat-row-copy > span { min-width: 0; display: flex; justify-content: space-between; gap: 8px; }
.chat-row-copy strong, .chat-row-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row-copy small, .chat-row-copy time { color: var(--muted); font-size: .77rem; }
.chat-unread { min-width: 24px; height: 24px; display: grid; place-items: center; padding: 0 6px; border-radius: 999px; background: #ff3155; color: #fff; font: 800 .72rem/1 system-ui, sans-serif; }
.chat-invite-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 12px 12px 75px; }
.chat-invite-actions button { min-height: 44px; border: 2px solid var(--outline); border-radius: 12px; background: var(--white); }
.chat-invite-actions button:last-child { background: #4bd99f; }
.chat-empty { display: grid; justify-items: center; gap: 11px; padding: 44px 24px; border: 2px solid var(--outline); border-radius: 22px; background: var(--white); text-align: center; }
.chat-empty > span { font-size: 3rem; }
.chat-empty h2, .chat-empty p { margin: 0; }
.chat-empty p { max-width: 32ch; color: var(--muted); }
.chat-room-screen,
[data-chat-settings-dialog] { --chat-appearance-font: var(--app-font); --chat-appearance-color: #003f42; --chat-outgoing-text: #fff; }
[data-chat-font="system"] { --chat-appearance-font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
[data-chat-font="rounded"] { --chat-appearance-font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, sans-serif; }
[data-chat-font="serif"] { --chat-appearance-font: ui-serif, Georgia, Cambria, "Times New Roman", serif; }
[data-chat-font="monospaced"] { --chat-appearance-font: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
[data-chat-color="blue"] { --chat-appearance-color: #1f61d1; }
[data-chat-color="purple"] { --chat-appearance-color: #7a3db8; }
[data-chat-color="pink"] { --chat-appearance-color: #c7337a; }
[data-chat-color="orange"] { --chat-appearance-color: #c75214; }
[data-chat-color="green"] { --chat-appearance-color: #1f7a47; }
.chat-room-screen:not(.hidden) { height: calc(100dvh - 70px - var(--safe-bottom)); display: flex; flex-direction: column; overflow: hidden; font-family: var(--chat-appearance-font); }
.chat-room-screen button,
.chat-room-screen textarea,
.chat-room-screen input,
.chat-room-screen select { font-family: var(--chat-appearance-font); }
.chat-room-header { position: sticky; top: max(0px, env(safe-area-inset-top)); z-index: 9; grid-template-columns: 44px minmax(0, 1fr) 44px; padding: 4px 0 10px; background: var(--aqua); }
.chat-back { width: 44px; height: 44px; padding: 0; border: 0; background: transparent; font-size: 2.4rem; line-height: .9; }
.chat-room-title { min-width: 0; display: grid; justify-items: center; gap: 2px; padding: 2px; border: 0; background: transparent; }
.chat-room-title strong, .chat-room-title small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-room-title small { color: var(--muted); font-size: .72rem; }
.chat-room-title small:empty { display: none; }
.chat-room-screen > .chat-room-header { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 4px; }
.chat-room-tools { display: flex; align-items: center; gap: 0; }
.chat-room-tools .chat-icon-button { width: 44px; min-width: 44px; border: 0; background: transparent; box-shadow: none; }
.chat-memento-toolbar { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--ink); font: 700 .76rem/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.chat-memento-toolbar-pill { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 4px 8px; border: 1px solid var(--muted); border-radius: 999px; background: var(--peach); }
.chat-memento-toolbar.complete .chat-memento-toolbar-pill { background: var(--white); }
.chat-memento-toolbar-pill > .ui-icon { width: 16px; height: 16px; }
.chat-moment-streak { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 2px; color: var(--muted); font: 400 12px/1 var(--chat-appearance-font, var(--app-font)); }
.chat-moment-streak .ui-icon { width: 12px; height: 14px; color: var(--streak); fill: currentColor; stroke-width: 0; }
.chat-memento-toolbar .chat-moment-streak { margin-left: 2px; padding-left: 5px; border-left: 1px solid var(--muted); }
.chat-row-copy > span { align-items: center; }
.chat-row-copy > span > strong { flex: 0 1 auto; }
.chat-row-copy time { margin-left: auto; flex: 0 0 auto; }
.chat-create-submit { min-height: 44px; padding: 7px 12px; border: 0; border-radius: 12px; background: var(--peach); color: var(--on-peach); font-weight: 700; }
.chat-create-submit:disabled { opacity: .45; }
.chat-create-body { display: grid; gap: 12px; }
.chat-group-name { display: grid; gap: 5px; font-size: .8rem; }
.chat-group-name input, .chat-person-search { width: 100%; min-height: 48px; border: 2px solid var(--outline); border-radius: 15px; background: var(--white); }
.chat-group-name input { padding: 9px 12px; font-size: 16px; }
.chat-person-search { display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; padding: 0 11px; }
.chat-person-search input { min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16px; }
.chat-create-hint { margin: -2px 2px 2px; color: var(--muted); font-size: .78rem; }
.chat-people-list { display: grid; gap: 8px; }
.chat-person-row { min-height: 62px; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 11px; border: 2px solid var(--outline); border-radius: 15px; background: var(--white); }
.chat-person-row > img, .chat-person-row > span:first-child { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--outline); border-radius: 50%; object-fit: cover; background: var(--peach); color: var(--on-peach); }
.chat-person-row > span:nth-child(2) { min-width: 0; display: grid; gap: 2px; }
.chat-person-row small { color: var(--muted); font-size: .73rem; }
.chat-person-row input { width: 24px; height: 24px; accent-color: #1eb780; }
.chat-daily-row { display: grid; gap: 10px; margin-bottom: 10px; }
.chat-memento-week { display: grid; grid-template-columns: repeat(7, minmax(40px, 1fr)); gap: 5px; padding: 3px 1px; overflow-x: auto; scrollbar-width: none; }
.chat-memento-week::-webkit-scrollbar { display: none; }
.chat-memento-week button { min-width: 40px; min-height: 56px; display: grid; place-items: center; align-content: center; gap: 1px; padding: 3px 1px; border: 1px solid rgba(5,9,20,.18); border-radius: 13px; background: rgba(255,255,255,.68); color: var(--muted); box-shadow: 0 2px 0 rgba(5,9,20,.04); }
.chat-memento-week button.selected { border: 2px solid var(--outline); background: var(--peach); color: var(--on-peach); box-shadow: 0 3px 0 rgba(5,9,20,.12); transform: translateY(-1px); }
.chat-memento-week button small { font: 800 .58rem/1 system-ui, sans-serif; text-transform: uppercase; }
.chat-memento-week button strong { font-size: .94rem; line-height: 1.15; }
.chat-memento-week button span { font: 700 .52rem/1 system-ui, sans-serif; }
.chat-memento-week button i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .42; }
.chat-daily-row > button { justify-self: center; width: 210px; max-width: 100%; min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 12px; border: 3px solid #000; border-radius: 999px; background: var(--peach); color: var(--on-peach); box-shadow: 4px 5px 0 #000; font-size: 16px; font-weight: 700; text-align: center; }
.chat-daily-row > button:active { transform: translate(3px, 4px); box-shadow: 1px 1px 0 #000; }
.chat-daily-icon { width: 24px; height: 24px; display: grid; place-items: center; background: transparent; }
.chat-daily-row.is-gate { flex: 0 1 auto; width: min(400px, calc(100% - 32px)); align-self: center; margin: auto; padding: 24px; gap: 20px; overflow-y: auto; border: 3px solid var(--outline); border-radius: 28px; background: var(--white); box-shadow: 0 8px 16px rgba(0,0,0,.14); text-align: center; }
.memento-gate-heading { display: grid; justify-items: center; gap: 8px; }
.memento-gate-icon { width: 64px; height: 64px; display: grid; place-items: center; margin-bottom: 12px; border-radius: 50%; background: rgba(255,177,94,.3); }
.memento-gate-icon .ui-icon { width: 28px; height: 28px; }
.memento-gate-heading h2 { margin: 0; font-size: 28px; line-height: 1.15; }
.memento-gate-heading p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.35; }
.chat-daily-row.is-gate > button { width: 100%; min-height: 54px; font-size: 18px; }
.memento-gate-skip { width: 100%; min-height: 44px; padding: 8px; border: 0; background: transparent; color: var(--muted); font-size: 16px; }
.chat-daily-row button:disabled { opacity: .55; cursor: default; }
.chat-room-screen:has(.chat-daily-row.is-gate:not(.hidden)) .chat-timeline.chat-content-locked { display: none; }
.chat-daily-row > button > span:nth-child(2) { display: grid; gap: 2px; }
.chat-daily-row small { color: var(--muted); font-size: .72rem; }
.chat-daily-progress { height: 4px; margin-top: 3px; overflow: hidden; border-radius: 99px; background: rgba(5,9,20,.1); }
.chat-daily-progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #f29d56, #ef5275); }
.chat-memento-strip { display: flex; gap: 9px; overflow-x: auto; padding: 0 2px 5px; scrollbar-width: none; scroll-snap-type: x proximity; }
.chat-memento-strip::-webkit-scrollbar { display: none; }
.chat-memento-strip button, .chat-memento-missing { flex: 0 0 76px; display: grid; justify-items: center; gap: 3px; padding: 0; border: 0; background: transparent; font-size: .67rem; text-align: center; scroll-snap-align: start; }
.chat-memento-strip img, .chat-memento-missing > i { width: 76px; height: 92px; display: grid; place-items: center; border: 2px solid var(--outline); border-radius: 14px; object-fit: cover; background: rgba(255,255,255,.62); box-shadow: 0 3px 0 rgba(5,9,20,.08); font-style: normal; font-size: 1.35rem; }
.chat-memento-missing small { margin-top: -3px; font-size: .56rem; }
.chat-timeline { min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 3px; overflow-x: hidden; overflow-y: auto; overflow-anchor: none; overscroll-behavior: contain; padding: 10px 2px 76px; scrollbar-width: none; }
.chat-timeline > * { flex-shrink: 0; }
.chat-timeline::before { content: ""; margin-top: auto; }
.chat-timeline::-webkit-scrollbar { display: none; }
.chat-history-edge { position: relative; align-self: center; min-height: 20px; color: var(--muted); font-size: .72rem; }
.chat-history-edge button { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.chat-history-edge.failed button, .chat-history-edge button:focus-visible { position: static; width: auto; height: auto; min-height: 44px; padding: 8px 14px; clip-path: none; border: 0; background: transparent; color: var(--ink); text-decoration: underline; }
.chat-jump-latest { position: fixed; z-index: 9; bottom: calc(150px + var(--safe-bottom)); right: max(20px, calc((100vw - 630px) / 2)); display: flex; align-items: center; gap: 5px; min-height: 44px; padding: 8px 13px; border: 1px solid color-mix(in srgb, var(--outline) 18%, transparent); border-radius: 24px; background: var(--card, #fff); color: var(--ink); box-shadow: 0 3px 12px rgba(0,0,0,.14); font-size: .75rem; }
.chat-jump-latest .ui-icon { width: 19px; height: 19px; }
:root[data-theme="dark"] .chat-jump-latest { background: #15373a; }
.chat-timeline.chat-content-locked { min-height: 36vh; opacity: .42; filter: blur(5px); pointer-events: none; user-select: none; }
.chat-room-empty { margin: auto; padding: 30px; color: var(--muted); text-align: center; }
.chat-room-empty p { margin: 7px 0 0; }
.chat-system-message { display: flex; justify-content: center; padding: 8px; color: var(--muted); font-size: .72rem; text-align: center; }
.chat-message { position: relative; max-width: 82%; display: grid; gap: 2px; }
.chat-message.mine { align-self: flex-end; justify-items: end; }
.chat-message.theirs { align-self: flex-start; justify-items: start; }
.chat-message-meta { padding: 0 8px; font-size: .68rem; }
.chat-bubble { position: relative; min-width: 72px; overflow: hidden; padding: 9px 11px 6px; border: 2px solid var(--outline); border-radius: 18px; background: var(--white); box-shadow: 0 2px 0 rgba(5,9,20,.08); }
.chat-message.mine .chat-bubble { background: var(--chat-appearance-color); color: var(--chat-outgoing-text); border-bottom-right-radius: 5px; }
.chat-message.theirs .chat-bubble { border-bottom-left-radius: 5px; }
.chat-message.mine:not(.ends-sequence) .chat-bubble { border-bottom-right-radius: 13px; }
.chat-message.mine:not(.starts-sequence) .chat-bubble { border-top-right-radius: 7px; }
.chat-message.theirs:not(.ends-sequence) .chat-bubble { border-bottom-left-radius: 13px; }
.chat-message.theirs:not(.starts-sequence) .chat-bubble { border-top-left-radius: 7px; }
.chat-message.deep-linked .chat-bubble { outline: 4px solid color-mix(in srgb, var(--peach) 72%, transparent); outline-offset: 3px; }
.chat-bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-bubble time { display: block; margin-top: 4px; color: rgba(5,9,20,.56); font: 600 .58rem/1 var(--chat-appearance-font); text-align: right; }
.chat-message.mine .chat-bubble time,
.chat-message.mine .memento-label { color: rgba(255,255,255,.76); }
.chat-message.mine .chat-reply-preview { border-left-color: currentColor; background: rgba(255,255,255,.18); color: var(--chat-outgoing-text); }
.chat-message.mine .chat-bubble a { color: var(--chat-outgoing-text); }
.chat-message.theirs .chat-bubble a { color: var(--chat-appearance-color); }
/* Fixed native boxes (ChatMessageBubble): photo/video 218², Memento 189×252,
   Story 218×286, sticker 176². The box never resizes when its image loads. */
.chat-message-media { position: relative; display: block; width: min(218px, 62vw); aspect-ratio: 1; margin: -9px -11px 6px; padding: 0; overflow: hidden; border: 0; background: color-mix(in srgb, var(--ink) 8%, transparent); }
.chat-message-media.memento { width: min(189px, 54vw); aspect-ratio: 3 / 4; }
.chat-message-media.story { aspect-ratio: 218 / 286; }
.chat-message-media > img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.chat-message-media > .chat-media-hash { z-index: 0; }
.chat-message-media > .chat-media-image { z-index: 1; }
.chat-message-media > .chat-media-image.media-placeholder { opacity: 0; }
.chat-message-media > .chat-media-text, .chat-message-media > .chat-video-play, .chat-message-media > .chat-video-status { z-index: 2; }
.chat-message-media.sticker { width: min(176px, 44vw); margin: -5px; background: transparent; }
.chat-message-media.sticker > img { object-fit: contain; }
.chat-media-text, .chat-viewer-overlay { position: absolute; z-index: 1; max-width: 88%; padding: 5px 8px; border-radius: 8px; background: rgba(5,9,20,.64); color: #fff; font-weight: 800; text-align: center; overflow-wrap: anywhere; transform: translate(-50%, -50%); }
.chat-video-play { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: rgba(5,9,20,.62); color: #fff; font-size: 1.2rem; transform: translate(-50%, -50%); }
.chat-video-status { position: absolute; left: 50%; top: 50%; display: inline-flex; align-items: center; gap: 8px; max-width: calc(100% - 20px); padding: 8px 12px; border-radius: 999px; background: rgba(5,9,20,.72); color: #fff; font-size: .8rem; font-weight: 600; line-height: 1.2; text-align: center; transform: translate(-50%, -50%); }
.chat-video-spinner { width: 14px; height: 14px; flex: none; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: chat-video-spin .9s linear infinite; }
@keyframes chat-video-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .chat-video-spinner { animation: none; } }
.chat-view-once-card { min-width: min(62vw, 250px); display: grid; gap: 3px; margin: -4px -6px 4px; padding: 18px 16px; border: 1px solid rgba(5,9,20,.24); border-radius: 14px; background: linear-gradient(135deg, #dffdfa, #ffe9c8); color: var(--ink); text-align: left; }
.chat-view-once-card small { color: var(--muted); }
.chat-view-once-card:disabled { opacity: .66; }
.chat-audio-message { min-width: min(64vw, 260px); display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px 8px; padding: 7px 2px; }
.chat-audio-message strong { font-size: .76rem; }
.chat-audio-message audio { grid-column: 1 / -1; width: 100%; height: 36px; }
.chat-audio-message small { color: var(--muted); }
.chat-audio-message.unavailable { color: var(--muted); }
.memento-label { display: block; margin: 2px 0 4px; color: rgba(5,9,20,.66); font-size: .69rem; }
.chat-reply-preview { width: 100%; display: grid; gap: 2px; margin-bottom: 6px; padding: 6px 8px; border: 0; border-left: 3px solid var(--outline); border-radius: 5px; background: rgba(255,255,255,.45); text-align: left; }
.chat-reply-preview span { overflow: hidden; font-size: .67rem; text-overflow: ellipsis; white-space: nowrap; }
.chat-message-menu-button { position: absolute; bottom: 1px; width: 30px; height: 24px; display: grid; place-items: center; padding: 0 0 5px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: 800 .72rem/1 system-ui, sans-serif; opacity: 0; transition: opacity .14s ease; }
.chat-message.mine .chat-message-menu-button { left: 2px; }
.chat-message.theirs .chat-message-menu-button { right: 2px; }
.chat-message:hover .chat-message-menu-button, .chat-message:focus-within .chat-message-menu-button, .chat-message.actions-open .chat-message-menu-button { opacity: 1; }
.chat-message-actions { position: fixed; inset: auto; left: var(--chat-actions-left, 12px); top: var(--chat-actions-top, 12px); margin: 0; box-sizing: border-box; width: var(--chat-actions-width, min(320px, calc(100vw - 24px))); max-width: none; max-height: var(--chat-actions-height, calc(100dvh - 24px)); overflow: auto; overscroll-behavior: contain; display: none; gap: 8px; padding: 9px; border: 1px solid rgba(5,9,20,.12); border-radius: 18px; background: var(--white); color: var(--ink); box-shadow: 0 8px 18px rgba(0,0,0,.2); }
.chat-message-actions[open] { display: grid; animation: chat-actions-in .14s ease-out; }
.chat-message-actions::backdrop { background: rgba(0,0,0,.08); }
.chat-message.actions-open > .chat-bubble { transform: scale(1.025); box-shadow: 0 5px 12px rgba(0,0,0,.2); }
.chat-bubble { -webkit-touch-callout: none; user-select: none; }
.chat-message-actions hr { width: 100%; margin: 0; border: 0; border-top: 1px solid rgba(5,9,20,.12); }
.chat-reaction-picker { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.chat-action-pair { display: flex; gap: 8px; }
.chat-action-pair > button { flex: 1; }
.chat-message-actions button { display: flex; align-items: center; justify-content: center; gap: 5px; min-width: 0; min-height: 44px; padding: 2px 8px; border: 1px solid rgba(5,9,20,.1); border-radius: 14px; background: rgba(255,255,255,.86); color: var(--ink); font-size: 12px; }
.chat-message-actions button:active { background: rgba(255,177,94,.5); transform: scale(.97); }
.chat-message-actions .ui-icon { width: 16px; height: 16px; flex-shrink: 0; }
.chat-reaction-picker button { min-height: 44px; padding: 0; border-radius: 12px; font-size: 25px; line-height: 1; background: rgba(255,255,255,.82); }
.chat-reaction-picker button.active { background: rgba(255,177,94,.42); border: 2px solid #0d3b3f; }
.chat-message-actions button.danger { color: #c83245; }
.chat-message-actions .chat-save-action { display: grid; justify-content: stretch; text-align: left; gap: 3px; min-height: 56px; padding: 6px 12px; }
.chat-save-action > span { display: flex; align-items: center; gap: 5px; font-size: 14px; }
.chat-save-action > small { font-size: 12px; color: var(--muted); }
.chat-action-footer { display: flex; align-items: center; justify-content: center; gap: 8px; }
.chat-action-footer button { min-height: 44px; border: 0; background: transparent; font-size: 11px; }
.chat-reaction-summary { display: flex; gap: 4px; margin-top: -6px; padding: 3px 7px; border: 1px solid rgba(5,9,20,.25); border-radius: 999px; background: var(--white); font: 700 .66rem/1.3 system-ui, sans-serif; box-shadow: 0 2px 0 rgba(5,9,20,.06); }
.chat-read-receipt { padding: 2px 5px; border: 0; background: transparent; color: var(--muted); font: 600 .6rem/1.2 system-ui, sans-serif; }
@keyframes chat-actions-in { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.chat-send-failure { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px; }
.chat-retry, .chat-discard { min-height: 44px; padding: 4px 12px; border: 0; border-radius: 999px; background: transparent; color: #c32243; font-size: 12px; font-weight: 700; }
.chat-discard { color: var(--muted); font-weight: 600; }
.chat-typing { position: fixed; z-index: 7; bottom: calc(139px + var(--safe-bottom)); padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.88); color: var(--muted); font-size: .7rem; }
.chat-reply-draft { position: fixed; z-index: 8; left: 50%; bottom: calc(133px + var(--safe-bottom)); width: min(620px, calc(100% - 28px)); display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border: 2px solid var(--outline); border-bottom: 0; border-radius: 13px 13px 0 0; background: #fff4dc; font-size: .72rem; transform: translateX(-50%); }
.chat-reply-draft span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-reply-draft { align-items: center; }
.chat-reply-draft button { flex: 0 0 44px; width: 44px; height: 44px; margin: -10px -8px -10px 0; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: var(--ink); }
.chat-reply-draft button .ui-icon { width: 16px; height: 16px; }
.chat-composer { position: fixed; z-index: 8; left: 50%; bottom: calc(82px + var(--safe-bottom)); width: min(650px, calc(100% - 20px)); min-height: 54px; display: grid; grid-template-columns: 40px 40px minmax(0, 1fr) 40px; align-items: end; gap: 4px; padding: 6px; border: 2px solid var(--outline); border-radius: 20px; background: rgba(255,255,255,.97); box-shadow: 0 7px 22px rgba(5,9,20,.18); transform: translateX(-50%); }
.chat-memento-draft { grid-column: 1 / -1; min-width: 0; display: grid; grid-template-columns: 48px minmax(0, 1fr) 44px; align-items: center; gap: 9px; padding: 5px; border-radius: 14px; background: #fff4dc; }
.chat-memento-draft img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; }
.chat-memento-draft span { min-width: 0; display: grid; gap: 2px; }
.chat-memento-draft strong, .chat-memento-draft small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-memento-draft strong { font-size: .76rem; }
.chat-memento-draft small { color: var(--muted); font-size: .66rem; }
.chat-memento-draft button { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; font-size: 1.25rem; }
.chat-room-screen:has(.chat-memento-draft:not(.hidden)) .chat-timeline { padding-bottom: 140px; }
.chat-room-screen:has(.chat-memento-draft:not(.hidden)) .chat-reply-draft { bottom: calc(195px + var(--safe-bottom)); }
.chat-composer textarea { width: 100%; min-height: 40px; max-height: 120px; resize: none; padding: 9px 10px; border: 0; border-radius: 13px; background: #f0f2f2; outline: 0; }
.chat-camera-button, .chat-attachment-button, .chat-send-button { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; }
.chat-camera-button, .chat-attachment-button { width: 44px; height: 44px; border: 2px solid var(--outline); background: var(--white); }
.chat-attachment-button { color: #ffb15e; }
.chat-attachment-button .native-sticker-icon { width: 21px; height: 21px; }
.chat-attachment-button .native-sticker-icon { filter: drop-shadow(.45px 0 currentColor) drop-shadow(-.45px 0 currentColor) drop-shadow(0 .45px currentColor) drop-shadow(0 -.45px currentColor); }
.chat-send-button { background: var(--peach); color: var(--on-peach); font-size: 1.4rem; }
.chat-sheet { width: min(520px, calc(100% - 22px)); max-height: min(780px, calc(100dvh - 24px)); margin: auto; padding: 0; overflow: auto; border: 0; border-radius: 24px; background: var(--aqua); }
.chat-sheet::backdrop, .chat-media-viewer::backdrop { background: rgba(5,9,20,.72); backdrop-filter: blur(3px); }
.memento-form, .chat-media-form, .chat-settings-content, .chat-reactors-content, .chat-readers-content { display: grid; gap: 13px; padding: 17px; }
.memento-form header, .chat-media-form header, .chat-settings-content > header, .chat-reactors-content > header, .chat-readers-content > header { display: grid; grid-template-columns: 70px minmax(0, 1fr) 70px; align-items: center; text-align: center; }
.memento-form header button, .chat-media-form header button, .chat-settings-content header button, .chat-reactors-content header button, .chat-readers-content header button { min-height: 44px; padding: 4px; border: 0; background: transparent; text-align: left; }
.chat-reactors-list { display: grid; gap: 2px; }
.chat-reactors-list > div { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 4px; border-bottom: 1px solid rgba(5,9,20,.12); }
.chat-reactors-list b { font-size: 1.25rem; }
.memento-preview, .chat-media-preview { position: relative; display: grid; align-content: center; justify-items: center; gap: 10px; overflow: hidden; border: 3px solid var(--outline); border-radius: 22px; background: #e6ffff; text-align: center; }
.memento-preview { aspect-ratio: 3 / 4; }
.chat-media-preview { aspect-ratio: 4 / 5; }
.memento-preview span { font-size: 4rem; }
.memento-preview p { margin: 0; color: var(--muted); }
.memento-preview img { width: 100%; height: 100%; object-fit: cover; }
.memento-preview .memento-preview-swap { position: absolute; top: 2.8%; right: 3.7%; width: 33%; height: 33%; padding: 0; border: 0; border-radius: 10%; background: transparent; cursor: pointer; }
.memento-preview .memento-preview-swap:focus-visible { outline: 4px solid #fff; outline-offset: -5px; box-shadow: 0 0 0 2px var(--ink); }
.chat-media-preview img, .chat-media-preview video { width: 100%; height: 100%; object-fit: contain; background: #050914; }
.chat-media-preview audio { width: min(90%, 360px); }
.memento-capture-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.memento-capture-inputs label { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: .72rem; font-weight: 800; }
.memento-file-input, .memento-secondary-file-input, .chat-media-file-input { width: 100%; min-width: 0; padding: 10px; border: 2px dashed var(--outline); border-radius: 13px; background: var(--white); color: inherit; }
.memento-capture-hint { margin: -4px 2px 0; color: var(--muted); line-height: 1.35; }
.memento-form > label, .chat-media-form > label { display: grid; gap: 5px; font-size: .8rem; }
.memento-audience { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 10px; border: 1px solid var(--outline); border-radius: 13px; font-size: .8rem; }
.memento-audience strong { color: var(--muted); }
.memento-audience span { min-width: 0; overflow-wrap: anywhere; text-align: right; font-weight: 800; }
.chat-media-form > .chat-media-option { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 8px; }
.chat-audio-input-label input { width: 100%; padding: 9px; border: 2px dashed var(--outline); border-radius: 13px; background: var(--white); }
.chat-media-option small { grid-column: 2; color: var(--muted); }
.chat-voice-record { min-height: 46px; border: 2px solid var(--outline); border-radius: 13px; background: var(--white); font-weight: 800; }
.chat-voice-record.recording { background: #ffe3e9; color: #9d1832; }
.chat-sticker-library { display: grid; gap: 7px; }
.chat-sticker-library > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chat-sticker-library h2 { margin: 0; font-size: .8rem; }
.chat-sticker-library > header button { min-height: 44px; padding: 6px 10px; border: 1px solid var(--outline); border-radius: 11px; background: var(--white); font-weight: 800; }
.chat-sticker-library > header button { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.native-sticker-icon { display: inline-block; width: 24px; height: 24px; flex: 0 0 auto; background: currentColor; mask: url("/assets/app/sticker-icon.webp") center / contain no-repeat; -webkit-mask: url("/assets/app/sticker-icon.webp") center / contain no-repeat; }
.chat-action-list button, .chat-add-people { display: inline-flex; align-items: center; gap: 5px; }
.chat-action-list .ui-icon { width: 18px; height: 18px; }
.chat-sticker-library > div { display: flex; gap: 8px; min-height: 54px; overflow-x: auto; }
.chat-sticker-item { flex: 0 0 62px; width: 62px; display: grid; gap: 4px; }
.chat-sticker-item [data-send-sticker] { width: 58px; height: 58px; padding: 3px; border: 1px solid var(--outline); border-radius: 13px; background: var(--white); }
.chat-sticker-item [data-delete-sticker] { width: 58px; min-height: 44px; padding: 3px; border: 1px solid #9d1832; border-radius: 10px; background: #ffe3e9; color: #9d1832; font-size: .62rem; font-weight: 800; }
.chat-sticker-library img { width: 100%; height: 100%; object-fit: contain; }
.chat-mementos-content, .chat-stickers-content { padding: 12px 16px max(20px, env(safe-area-inset-bottom)); color: var(--ink); }
.chat-mementos-content > header, .chat-stickers-content > header { display: grid; grid-template-columns: 60px minmax(0, 1fr) 60px; align-items: center; gap: 4px; text-align: center; }
.chat-mementos-content > header button, .chat-stickers-content > header button { min-height: 44px; padding: 4px; border: 0; background: transparent; color: var(--ink); font-weight: 600; }
.chat-mementos-content > p, .chat-stickers-content > p { color: var(--muted); font-size: .85rem; text-align: center; }
.chat-memento-gallery-status:empty, .chat-sticker-status:empty { display: none; }
.chat-memento-gallery h2 { margin: 20px 0 4px; text-align: center; font-size: 1.2rem; }
.chat-memento-gallery > p { margin: 0 0 18px; color: var(--muted); font-size: .82rem; text-align: center; }
.chat-memento-gallery .chat-memento-week { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin-top: 12px; }
.chat-memento-gallery .chat-memento-week button { min-width: 0; background: var(--white); color: var(--ink); box-shadow: none; }
.chat-memento-gallery .chat-memento-week button.selected { background: var(--peach); color: var(--on-peach); }
.chat-memento-gallery .chat-memento-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; overflow: visible; }
.chat-memento-gallery .chat-memento-strip button, .chat-memento-gallery .chat-memento-missing { min-width: 0; width: 100%; align-content: start; gap: 7px; font-size: .82rem; color: var(--ink); }
.chat-memento-gallery .chat-memento-strip img, .chat-memento-gallery .chat-memento-missing > i { width: 100%; height: auto; aspect-ratio: 3 / 4; border: 0; border-radius: 18px; background: var(--white); box-shadow: none; }
.chat-memento-gallery .chat-memento-missing small { font-size: .72rem; color: var(--muted); }
.chat-stickers-sheet .chat-sticker-library { margin-top: 22px; gap: 16px; }
.chat-stickers-sheet .chat-sticker-library > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; overflow: visible; }
.chat-stickers-sheet .chat-sticker-library > div > small { grid-column: 1 / -1; color: var(--muted); }
.chat-stickers-sheet .chat-sticker-item { width: 100%; min-width: 0; }
.chat-stickers-sheet .chat-sticker-item [data-send-sticker] { width: 100%; height: auto; aspect-ratio: 1; padding: 8px; border: 0; border-radius: 18px; }
.chat-stickers-sheet .chat-sticker-item [data-delete-sticker] { width: 100%; }
.chat-stickers-sheet:not(.is-editing) [data-delete-sticker] { display: none; }
@media (max-width: 540px) {
    .chat-mementos-sheet, .chat-stickers-sheet { width: 100%; max-width: 100%; max-height: calc(100dvh - max(12px, env(safe-area-inset-top))); margin: auto auto 0; border-radius: 24px 24px 0 0; }
    .chat-mementos-sheet { height: calc(100dvh - max(12px, env(safe-area-inset-top))); }
    .chat-stickers-sheet { min-height: min(480px, 80dvh); }
}
.chat-sticker-maker { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); border: 0; background: #050914; color: #fff; }
.chat-sticker-maker::backdrop { background: #050914; }
.chat-sticker-maker-form { width: min(100%, 620px); min-height: 100%; margin: 0 auto; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto; gap: 12px; }
.chat-sticker-maker-form > header { display: grid; grid-template-columns: 70px minmax(0, 1fr) 70px; align-items: center; min-height: 46px; }
.chat-sticker-maker-form > header strong { text-align: center; }
.chat-sticker-maker-form > header button { min-height: 44px; border: 0; background: transparent; color: #fff; text-align: left; }
.chat-sticker-canvas { min-height: 0; display: grid; place-items: center; overflow: hidden; border: 1px solid rgba(255,255,255,.2); border-radius: 20px; background: #050914; }
.chat-sticker-canvas canvas { width: min(100%, 70vh, 620px); height: auto; max-height: 100%; aspect-ratio: 1; touch-action: none; }
.chat-sticker-canvas canvas:focus-visible { outline: 4px solid var(--peach); outline-offset: -5px; }
.chat-sticker-maker-form > p { margin: 0; color: rgba(255,255,255,.78); font-size: .8rem; line-height: 1.4; text-align: center; }
.chat-sticker-maker-form [data-sticker-maker-status] { min-height: 1.4em; color: #fff; font-weight: 800; }
.chat-sticker-maker-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.chat-sticker-maker-actions button { min-height: 50px; padding: 8px; border: 2px solid #fff; border-radius: 14px; background: transparent; color: #fff; font-weight: 800; }
.chat-sticker-maker-actions .primary-button { background: var(--peach); color: var(--on-peach); }
.chat-sticker-maker-actions button:disabled { opacity: .52; }
.memento-form input[type="text"], .memento-caption, .chat-media-overlay { min-height: 46px; padding: 8px 11px; border: 2px solid var(--outline); border-radius: 12px; background: var(--white); }
.memento-progress, .chat-media-progress { height: 8px; overflow: hidden; border-radius: 999px; background: rgba(5,9,20,.12); }
.memento-progress span, .chat-media-progress span { display: block; height: 100%; background: #1eb780; transition: width .15s linear; }
.memento-progress span:not([data-valid-runtime-style]), .chat-media-progress span:not([data-valid-runtime-style]) { width: 0; }
.memento-status, .chat-media-status { min-height: 1.3em; margin: -4px 0; color: var(--muted); font-size: .78rem; text-align: center; }
.memento-skip { min-height: 44px; border: 0; background: transparent; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.chat-media-viewer { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); border: 0; background: #050914; color: #fff; }
.chat-media-viewer button { position: absolute; z-index: 2; top: max(12px, env(safe-area-inset-top)); right: 14px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff; font-size: 1.8rem; }
.chat-media-viewer img, .chat-media-viewer video { width: 100%; height: calc(100% - 52px); object-fit: contain; }
.chat-viewer-overlay { max-width: min(80vw, 560px); font-size: clamp(1rem, 4vw, 1.6rem); }
.chat-media-viewer p { margin: 10px 0 0; text-align: center; }
.chat-viewer-actions { position: absolute; z-index: 3; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 24px); display: flex; gap: 8px; padding: 2px; overflow-x: auto; transform: translateX(-50%); scrollbar-width: none; }
.chat-viewer-actions::-webkit-scrollbar { display: none; }
.chat-viewer-actions button { position: static; width: auto; height: 44px; padding: 0 14px; border-radius: 999px; font-size: .82rem; white-space: nowrap; }
.chat-settings-content section { display: grid; gap: 8px; padding: 11px; border: 2px solid var(--outline); border-radius: 15px; background: var(--white); }
.chat-settings-content h3 { margin: 0 0 4px; }
.chat-settings-member { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid rgba(5,9,20,.1); }
.chat-settings-member small { color: var(--muted); }
.chat-settings-member button { min-height: 44px; padding: 4px 8px; border: 1px solid #bd2846; border-radius: 9px; background: #ffe3e9; color: #9d1832; font-size: .7rem; }
.chat-member-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.chat-add-people { min-height: 44px; border: 1px dashed var(--outline); border-radius: 11px; background: #e6ffff; }
.chat-name-setting { display: grid; gap: 5px; }
.chat-photo-setting { display: grid; gap: 5px; font-size: .8rem; }
.chat-photo-setting input { width: 100%; padding: 9px; border: 2px dashed var(--outline); border-radius: 12px; background: var(--white); }
.chat-name-setting > span { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.chat-name-setting input { min-width: 0; min-height: 44px; padding: 8px 10px; font-size: 16px; border: 2px solid var(--outline); border-radius: 11px; background: var(--white); }
.chat-name-setting button { min-height: 44px; padding: 7px 12px; border: 2px solid var(--outline); border-radius: 11px; background: var(--peach); color: var(--on-peach); }
.chat-notification-setting { display: grid; gap: 5px; }
.chat-notification-setting select { min-height: 46px; padding: 8px; border: 2px solid var(--outline); border-radius: 12px; background: var(--white); }
.chat-appearance-setting > label { display: grid; gap: 5px; }
.chat-appearance-setting select { min-height: 46px; padding: 8px; border: 2px solid var(--outline); border-radius: 12px; background: var(--white); }
.chat-color-options { display: grid; grid-template-columns: repeat(6, minmax(42px, 1fr)); gap: 7px; }
.chat-color-options button { min-width: 42px; min-height: 46px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; }
.chat-color-options button > span { width: 38px; height: 38px; border: 3px solid transparent; border-radius: 50%; background: #003f42; box-shadow: 0 0 0 1px rgba(5,9,20,.2); }
.chat-color-options button[data-chat-appearance-color="blue"] > span { background: #1f61d1; }
.chat-color-options button[data-chat-appearance-color="purple"] > span { background: #7a3db8; }
.chat-color-options button[data-chat-appearance-color="pink"] > span { background: #c7337a; }
.chat-color-options button[data-chat-appearance-color="orange"] > span { background: #c75214; }
.chat-color-options button[data-chat-appearance-color="green"] > span { background: #1f7a47; }
.chat-color-options button.selected > span { border-color: #fff; box-shadow: 0 0 0 3px var(--ink); }
.chat-appearance-preview { justify-self: end; max-width: 86%; margin: 3px 0; padding: 9px 13px; border: 1.5px solid var(--outline); border-radius: 17px 17px 5px 17px; background: var(--chat-appearance-color); color: var(--chat-outgoing-text); font-family: var(--chat-appearance-font); }
.chat-appearance-setting > small { color: var(--muted); line-height: 1.35; }
.chat-danger-action { min-height: 46px; border: 2px solid #bd2846; border-radius: 13px; background: #ffe3e9; color: #9d1832; }

@media (hover: none), (max-width: 760px) {
    .chat-message { max-width: 88%; }
}

@media (prefers-reduced-motion: reduce) {
    .chat-message-actions, .chat-message-menu-button, .memento-progress span { transition: none; animation: none; }
}

:root[data-theme="dark"] .chat-room-screen,
:root[data-theme="dark"] [data-chat-settings-dialog] { --chat-appearance-color: #0a6166; --chat-outgoing-text: #edf3f3; }
:root[data-theme="dark"] [data-chat-color="blue"] { --chat-appearance-color: #194ea6; }
:root[data-theme="dark"] [data-chat-color="purple"] { --chat-appearance-color: #643096; }
:root[data-theme="dark"] [data-chat-color="pink"] { --chat-appearance-color: #9e285f; }
:root[data-theme="dark"] [data-chat-color="orange"] { --chat-appearance-color: #943908; }
:root[data-theme="dark"] [data-chat-color="green"] { --chat-appearance-color: #17643a; }
:root[data-theme="dark"] .chat-memento-week button,
:root[data-theme="dark"] .chat-load-earlier,
:root[data-theme="dark"] .chat-typing { background: rgba(var(--surface-rgb),.9); border-color: rgba(245,251,251,.22); }
:root[data-theme="dark"] .chat-memento-gallery .chat-memento-week button.selected { background: var(--peach); color: var(--on-peach); border-color: var(--peach); }
:root[data-theme="dark"] .chat-memento-strip img,
:root[data-theme="dark"] .chat-memento-missing > i { background: rgba(var(--surface-rgb),.72); border-color: rgba(245,251,251,.28); }
:root[data-theme="dark"] .chat-message.mine .chat-bubble { background: var(--chat-appearance-color); }
:root[data-theme="dark"] .chat-bubble time,
:root[data-theme="dark"] .memento-label { color: rgba(245,251,251,.7); }
:root[data-theme="dark"] .chat-reply-preview { background: rgba(7,24,26,.45); }
:root[data-theme="dark"] .chat-message-actions,
:root[data-theme="dark"] .chat-composer { background: rgba(var(--surface-rgb),.98); }
:root[data-theme="dark"] .chat-message-actions button,
:root[data-theme="dark"] .chat-composer textarea,
:root[data-theme="dark"] .chat-search-form label,
:root[data-theme="dark"] .chat-search-results button,
:root[data-theme="dark"] .memento-file-input,
:root[data-theme="dark"] .memento-secondary-file-input,
:root[data-theme="dark"] .chat-media-file-input,
:root[data-theme="dark"] .chat-audio-input-label input,
:root[data-theme="dark"] .chat-voice-record,
:root[data-theme="dark"] .chat-media-overlay { background: #0f2c2f; border-color: rgba(245,251,251,.2); color: var(--ink); }
:root[data-theme="dark"] .chat-message-actions button.active { background: #5b3541; }
:root[data-theme="dark"] .chat-reply-draft,
:root[data-theme="dark"] .chat-memento-draft { background: #493c21; }
:root[data-theme="dark"] .memento-preview,
:root[data-theme="dark"] .chat-media-preview,
:root[data-theme="dark"] .chat-add-people { background: #0f3437; }
:root[data-theme="dark"] .chat-view-once-card { background: linear-gradient(135deg, #17484c, #493c21); color: var(--ink); }
:root[data-theme="dark"] .chat-retry,
:root[data-theme="dark"] .chat-settings-member button,
:root[data-theme="dark"] .chat-danger-action { background: #4b202b; color: #ffb6c5; }
:root[data-theme="dark"] .chat-color-options button[data-chat-appearance-color="teal"] > span { background: #0a6166; }
:root[data-theme="dark"] .chat-color-options button[data-chat-appearance-color="blue"] > span { background: #194ea6; }
:root[data-theme="dark"] .chat-color-options button[data-chat-appearance-color="purple"] > span { background: #643096; }
:root[data-theme="dark"] .chat-color-options button[data-chat-appearance-color="pink"] > span { background: #9e285f; }
:root[data-theme="dark"] .chat-color-options button[data-chat-appearance-color="orange"] > span { background: #943908; }
:root[data-theme="dark"] .chat-color-options button[data-chat-appearance-color="green"] > span { background: #17643a; }

/* The room owns one visual-viewport-sized layout. Composer space is not counted
   again as fixed navigation/keyboard padding inside the scrolling timeline. */
.chat-room-screen:not(.hidden) { position: fixed; z-index: 11; top: var(--visual-viewport-top, 0px); left: var(--visual-viewport-center, 50%); width: min(650px, var(--visual-viewport-width, 100%)); height: calc(var(--visual-viewport-height, 100dvh) - 78px - var(--safe-bottom)); transform: translateX(-50%); background: var(--aqua); padding: max(0px, env(safe-area-inset-top)) 8px 0; }
.keyboard-open .chat-room-screen:not(.hidden) { height: var(--visual-viewport-height, 100dvh); padding-bottom: 6px; }
.chat-room-screen > .chat-room-header { position: relative; top: auto; flex: 0 0 auto; }
.chat-room-screen .chat-timeline, .chat-room-screen:has(.chat-memento-draft:not(.hidden)) .chat-timeline { padding: 10px 2px 8px; }
.chat-room-screen .chat-composer { position: relative; flex: 0 0 auto; left: auto; bottom: auto; width: 100%; transform: none; grid-template-columns: 44px 44px minmax(0, 1fr) auto; gap: 8px; padding: 8px 2px; border: 0; border-radius: 0; box-shadow: none; background: var(--aqua); align-items: end; }
.chat-input-wrap { min-width: 0; display: flex; align-items: end; min-height: 44px; border: 2px solid var(--outline); border-radius: 24px; overflow: hidden; background: var(--white); }
.chat-composer .chat-input-wrap textarea { min-width: 0; min-height: 40px; border-radius: 0; background: transparent; padding: 9px 8px 9px 12px; font-size: 16px; line-height: 1.35; overflow-y: hidden; }
.chat-mic-button { flex: 0 0 44px; width: 44px; height: 44px; margin: -2px 0; padding: 11px; border: 0; background: transparent; color: var(--ink); }
.chat-mic-button.recording { color: #e83950; }
.chat-composer .chat-send-button { display: none; height: 44px; width: 44px; }
.chat-composer:has(textarea:not(:placeholder-shown)) .chat-send-button, .chat-composer:has(.chat-memento-draft:not(.hidden)) .chat-send-button { display: grid; }
.chat-room-screen .chat-reply-draft, .chat-room-screen .chat-typing { position: relative; flex: 0 0 auto; left: auto; bottom: auto; width: 100%; transform: none; }
.chat-room-screen .chat-jump-latest { position: absolute; bottom: 80px; right: 14px; }
.chat-voice-inline { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-voice-inline > div { flex: 1; min-width: 0; }
.chat-voice-inline p { margin: 0; font-size: 13px; }
.chat-voice-inline audio { width: 100%; height: 42px; }
.chat-voice-inline button { width: 44px; height: 44px; flex-shrink: 0; border: 0; border-radius: 50%; background: var(--peach); color: var(--on-peach); }
.chat-composer.voice-mode .chat-camera-button, .chat-composer.voice-mode .chat-attachment-button, .chat-composer.voice-mode .chat-send-button, .chat-composer.voice-mode textarea { display: none; }
.chat-composer.voice-mode .chat-input-wrap { grid-column: 1 / -1; align-items: center; justify-content: space-between; }
.chat-composer.voice-mode .chat-input-wrap::before { content: 'Voice message'; padding-left: 12px; font-size: 14px; }
:root[data-theme="dark"] .chat-room-screen .chat-composer { background: var(--aqua); }
:root[data-theme="dark"] .chat-input-wrap { background: #123235; }
:root[data-theme="dark"] .chat-composer .chat-input-wrap textarea { background: transparent; }
.chat-voice-inline [data-cancel-voice] { background: var(--white); color: #e83950; border: 2px solid var(--outline); }

/* Match native review hierarchy: tools on the photo, delivery pill and send. */
.chat-camera-sheet .chat-media-form { grid-template-rows: auto minmax(0, 1fr); }
.chat-camera-sheet .chat-media-editor { position: relative; overflow: hidden; }
.chat-camera-sheet .chat-media-preview { flex: 1 1 0; height: 100%; min-height: 0; aspect-ratio: auto; }
.chat-camera-sheet .chat-media-preview > img, .chat-camera-sheet .chat-media-preview > video { background: #000; }
.chat-camera-sheet:has(.chat-media-preview > img) .chat-media-form > header,
.chat-camera-sheet:has(.chat-media-preview > video) .chat-media-form > header { display: none; }
.chat-camera-sheet:has(.chat-media-preview > img) .chat-media-form,
.chat-camera-sheet:has(.chat-media-preview > video) .chat-media-form { grid-template-rows: minmax(0, 1fr); }
.chat-photo-tools { position: absolute; z-index: 4; inset: 12px 10px auto; display: flex; align-items: center; gap: 6px; }
.chat-call-history { display: flex; align-items: center; gap: 10px; align-self: flex-start; max-width: 88%; padding: 12px; margin: 4px 0; border-radius: 18px; background: var(--white); color: var(--ink); }
.chat-call-history.mine { align-self: flex-end; }
.chat-call-history-icon { display: grid; place-items: center; flex: 0 0 40px; height: 40px; border-radius: 50%; background: color-mix(in srgb, var(--peach) 22%, transparent); color: var(--peach); }
.chat-call-history.attention .chat-call-history-icon { color: #ef5275; background: #ef527522; }
.chat-call-history strong { display: block; font-size: 15px; }
.chat-call-history small { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.chat-call-history time { align-self: flex-end; margin-left: auto; white-space: nowrap; font-size: 10px; color: var(--muted); }
.chat-photo-tools > span { flex: 1; }
.chat-photo-tools button { display: flex; align-items: center; justify-content: center; gap: 5px; min-width: 44px; height: 44px; border: 0; border-radius: 99px; background: #0009; color: #fff; font-size: 14px; padding: 8px 10px; }
.chat-photo-tools [data-photo-stickers] { color: #ffb15e; }
.chat-photo-tools button[hidden] { display: none; }
.chat-photo-tools .native-sticker-icon { width: 23px; height: 23px; }
.chat-camera-sheet .chat-media-edit-options { display: none; }
.chat-camera-sheet .chat-media-edit-options[open] { display: block; position: absolute; z-index: 6; left: 8px; right: 8px; bottom: 92px; max-height: 55%; overflow: auto; background: #111e; padding: 12px; border-radius: 18px; }
.chat-media-edit-options summary, .chat-media-edit-options .camera-effect-picker small { display: none; }
.chat-camera-sheet .chat-media-option { position: absolute; z-index: 4; bottom: 20px; left: 12px; justify-content: start; padding: 0 14px; min-height: 48px; background: #0009; border: 2px solid #ffffff70; border-radius: 99px; color: #fff; font-size: 14px; }
.chat-media-option:has(input:checked) { background: var(--peach); color: var(--on-peach); }
.chat-camera-sheet .chat-media-option { display: flex; align-items: center; gap: 8px; line-height: 1; }
.chat-camera-sheet .chat-media-option input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.chat-media-option .ui-icon { display: block; flex: 0 0 24px; width: 24px; height: 24px; }
.chat-media-option [data-ui-icon="view-once"], .chat-media-option:has(input:checked) [data-ui-icon="infinity"] { display: none; }
.chat-media-option:has(input:checked) [data-ui-icon="view-once"] { display: block; }
.chat-media-option:has(input:focus-visible) { outline: 3px solid #fff; outline-offset: 3px; }
.chat-camera-sheet .chat-media-review-actions { position: absolute; right: 12px; bottom: 16px; z-index: 4; display: block; }
.chat-media-review-actions .chat-media-publish { width: 58px; height: 58px; padding: 12px; min-height: 58px; border: 3px solid #fff; background: var(--peach); color: var(--on-peach); border-radius: 50%; font-size: 11px; }
.chat-camera-sheet .chat-media-status { position: absolute; left: 12px; right: 12px; bottom: 80px; z-index: 5; margin: 0; font-size: 13px; text-align: center; background: #000b; border-radius: 10px; }
.chat-camera-sheet .chat-media-status:empty { display: none; }
.chat-camera-sheet .chat-media-progress { position: absolute; left: 16px; right: 16px; bottom: 78px; z-index: 5; }
.chat-camera-sheet .live-camera-hint { visibility: hidden; }
.chat-photo-sticker { position: absolute; z-index: 3; transform: translate(-50%, -50%); padding: 0; border: 0; background: transparent; touch-action: none; }
.chat-camera-sheet .chat-photo-sticker img { position: static; width: 100%; height: auto; background: transparent; display: block; pointer-events: none; }
.chat-photo-sticker:focus-visible { outline: 2px dashed #fff; outline-offset: 4px; }
.chat-photo-sticker-remove { position: absolute; z-index: 4; width: 44px; height: 44px; border: 0; border-radius: 50%; color: #fff; background: #000b; font: 28px system-ui; }
.chat-composer.voice-mode .chat-input-wrap { display: none; }
.chat-voice-inline [hidden] { display: none; }
.chat-voice-body { min-width: 0; padding: 5px 12px; border-radius: 22px; border: 2px solid var(--outline); background: var(--white); }
.chat-voice-waveform { display: block; width: 100%; height: 28px; }
.chat-voice-hint { font-size: 11px !important; color: var(--muted); }
.chat-voice-hint:empty { display: none; }
.chat-voice-player { display: flex; align-items: center; gap: 6px; }
.chat-voice-player [data-voice-play] { width: 44px; height: 44px; margin: -6px 0; background: transparent; color: var(--ink); }
.chat-voice-player input { min-width: 0; width: 100%; accent-color: var(--peach); }
.chat-voice-inline [data-stop-voice] { color: #e83950; background: var(--white); border: 2px solid var(--outline); }
.chat-mic-button { touch-action: none; -webkit-user-select: none; user-select: none; }
.chat-attachment-button .native-sticker-icon { filter: none; }
.chat-stickers-sheet .chat-sticker-item [data-send-sticker] { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.chat-sticker-new { aspect-ratio: 1; display: grid; place-content: center; justify-items: center; gap: 7px; border: 1.5px dashed #ffb15e; border-radius: 18px; background: linear-gradient(135deg, #f8abc477, #ffb15e55); color: var(--ink); }
.chat-sticker-new > span { display: grid; place-items: center; width: 42px; height: 42px; padding: 11px; border-radius: 50%; background: var(--peach); color: var(--on-peach); }
.chat-voice-body { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 8px; }
.chat-voice-waveform { height: 20px; }
.chat-voice-hint, .chat-voice-player { grid-column: 1 / -1; }
.chat-voice-player input { appearance: none; height: 4px; border: 0; border-radius: 4px; background: color-mix(in srgb, var(--ink) 18%, transparent); }
.chat-voice-player input::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--peach); }
.chat-voice-player input::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--peach); }
.chat-voice-inline [data-record-again] { background: var(--white); color: var(--ink); border: 2px solid var(--outline); }

/* ChatListView's recent-conversation shortcuts. Presence is a separate API. */
.chat-recent { min-width: 0; margin: 8px 0 16px; }
.chat-recent h2 { margin: 0 4px 10px; font-size: 14px; line-height: 1.2; color: var(--muted); }
.chat-recent-rail { display: flex; gap: 8px; overflow-x: auto; padding: 3px 1px; scrollbar-width: none; }
.chat-recent-rail::-webkit-scrollbar { display: none; }
.chat-recent-link { flex: 0 0 78px; min-width: 0; display: grid; justify-items: center; align-content: start; gap: 7px; color: var(--ink); text-decoration: none; }
.chat-recent-avatar { position: relative; display: grid; place-items: center; width: 70px; height: 70px; padding: 5px; }
.chat-recent-avatar::before { content: ""; position: absolute; inset: 0; border: 1.5px solid color-mix(in srgb, var(--outline) 16%, transparent); border-radius: 50%; }
.chat-recent-link.attention .chat-recent-avatar::before { border: 3px solid var(--peach); }
.chat-recent-avatar > img, .chat-recent-avatar > span { width: 60px; height: 60px; object-fit: cover; border-radius: 50%; }
.chat-recent-avatar > span { display: grid; place-items: center; background: var(--mint); color: var(--dark-teal); font-size: 23px; }
.chat-recent-name { max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; line-height: 1.25; }
.chat-recent-camera, .chat-recent-unread { position: absolute; top: 0; right: 0; border: 2px solid var(--aqua); border-radius: 50%; background: var(--peach); color: var(--on-peach); }
.chat-recent-camera { display: grid; place-items: center; width: 23px; height: 23px; color: #000; }
.chat-recent-camera .ui-icon { width: 13px; height: 13px; }
.chat-recent-unread { width: 14px; height: 14px; margin: 2px; }
.chat-moment-streak .ui-icon { color: var(--streak); fill: currentColor; }
:root[data-theme="dark"] .chat-moment-streak { color: var(--muted); }

.chat-avatar-mosaic { position: relative; display: grid; place-items: center; width: 100%; height: 100%; overflow: hidden; border-radius: 50%; background: var(--mint); color: var(--dark-teal); }
.chat-avatar-mosaic .chat-avatar-member { position: absolute; left: 50%; top: 50%; display: grid; place-items: center; width: 50%; height: 50%; transform: translate(-50%, -50%); border: 2px solid var(--white); border-radius: 50%; background: var(--mint); font-size: 11px; font-style: normal; overflow: hidden; }
.chat-avatar-member img { width: 100%; height: 100%; object-fit: cover; }
.chat-avatar-mosaic[data-member-count="1"] .chat-avatar-member { width: 78%; height: 78%; }
.chat-avatar-mosaic[data-member-count="2"] .chat-avatar-member { width: 64%; height: 64%; }
.chat-avatar-mosaic[data-member-count="2"] .chat-avatar-member:first-child { left: 34%; }
.chat-avatar-mosaic[data-member-count="2"] .chat-avatar-member:last-child { left: 66%; }
.chat-avatar-mosaic[data-member-count="3"] .chat-avatar-member { width: 56%; height: 56%; }
.chat-avatar-mosaic[data-member-count="3"] .chat-avatar-member:first-child { top: 32%; }
.chat-avatar-mosaic[data-member-count="3"] .chat-avatar-member:nth-child(2) { left: 32%; top: 67%; }
.chat-avatar-mosaic[data-member-count="3"] .chat-avatar-member:nth-child(3) { left: 68%; top: 67%; }
.chat-avatar-mosaic[data-member-count="4"] .chat-avatar-member { left: 32%; top: 32%; }
.chat-avatar-mosaic[data-member-count="4"] .chat-avatar-member:nth-child(even) { left: 68%; }
.chat-avatar-mosaic[data-member-count="4"] .chat-avatar-member:nth-child(n+3) { top: 68%; }

.chat-avatar-wrap { position: relative; display: block; width: 52px; height: 52px; }
.chat-presence-dot { position: absolute; right: 1px; bottom: 1px; width: 14px; height: 14px; border: 2px solid var(--aqua); border-radius: 50%; background: #38c879; }
.chat-presence-dot[hidden], .chat-presence-label[hidden] { display: none; }
.chat-recent-avatar .chat-presence-dot { right: 3px; bottom: 3px; }
.chat-presence-label { width: 78px; margin-top: -4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10px; line-height: 1.3; text-align: center; }
.chat-presence-label.is-active, .chat-room-title small.is-active, .chat-settings-member small.is-active { color: var(--dark-teal); }
.chat-room-title small.is-active::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: #38c879; }

/* Native chat inbox: distinct media actions, authoritative streak and Memento. */
.chat-row { position: relative; }
.chat-row-main { gap: 8px; }
.chat-row-copy > span { justify-content: flex-start; gap: 6px; }
.chat-row-copy strong { font-size: 16px; }
.chat-row-copy small { min-height: 28px; line-height: 28px; font-size: 14px; color: var(--ink); }
.chat-row-trailing { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; min-width: 42px; min-height: 52px; }
.chat-row-trailing time { font-size: 12px; color: var(--muted); margin-top: auto; }
.chat-needs-memento { margin: auto 0; color: var(--ink); }
.chat-needs-memento .ui-icon { width: 24px; height: 24px; }
.chat-row.has-inbox-action .chat-row-trailing { min-width: 76px; }
.chat-inbox-action { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); height: 44px; display: flex; align-items: center; gap: 6px; padding: 0 11px; border: 2px solid var(--outline); border-radius: 99px; background: var(--white); color: var(--ink); font-size: 14px; cursor: pointer; }
.chat-inbox-action i { width: 13px; height: 13px; border-radius: 3px; background: var(--heart-pink); }
.chat-inbox-action i.video { background: #7a3db8; }
.chat-inbox-action.missed { color: #fff; background: #d93649; }
.chat-inbox-action .ui-icon { width: 16px; height: 16px; }
.chat-memento-toolbar-pill { color: var(--dark-teal); background: color-mix(in srgb, var(--peach) 28%, transparent); border-color: color-mix(in srgb, var(--dark-teal) 20%, transparent); }
.chat-memento-toolbar.complete .chat-memento-toolbar-pill { background: color-mix(in srgb, var(--dark-teal) 10%, var(--white)); }
.chat-memento-toolbar-pill > .ui-icon { width: 17px; height: 17px; }
.chat-memento-toolbar .chat-moment-streak { color: var(--dark-teal); }
.chat-memento-toolbar .chat-moment-streak .ui-icon { color: var(--streak); }
.chat-presence-dot { top: 1px; bottom: auto; }
.chat-recent-avatar .chat-presence-dot { top: 3px; bottom: auto; }

/* Match native 174 x 56 ephemeral media, with photo/video color and state. */
.chat-message.ephemeral .chat-bubble, :root[data-theme="dark"] .chat-message.ephemeral .chat-bubble { background: transparent; border: 0; box-shadow: none; padding: 0; }
.chat-view-once-card, :root[data-theme="dark"] .chat-view-once-card { --media-marker: #e95f46; width: 174px; min-width: 0; height: 56px; display: flex; align-items: center; gap: 10px; margin: 0; padding: 0 14px; border: 2px solid var(--outline); border-radius: 19px; background: color-mix(in srgb, var(--peach) 22%, transparent); color: var(--dark-teal); text-align: left; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: pointer; }
.chat-view-once-card.video { --media-marker: #7a3db8; }
:root[data-theme="dark"] .chat-view-once-card.video { --media-marker: #643096; }
.chat-view-once-card strong { min-width: 0; font-size: 14px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-view-once-card.compact-label strong { font-size: 10.5px; }
.chat-view-once-card:disabled { opacity: 1; cursor: default; }
.chat-view-once-card.armed { background: color-mix(in srgb, var(--media-marker) 18%, transparent); }
.chat-media-marker { flex: 0 0 19px; width: 19px; height: 19px; color: var(--media-marker); display: grid; place-items: center; }
.chat-media-marker > span { width: 19px; height: 19px; border: 2.5px solid currentColor; border-radius: 4px; background: var(--media-marker); display: grid; place-items: center; }
.chat-media-marker .ui-icon { width: 9px; height: 9px; fill: #fff; color: #fff; }
.opened .chat-media-marker > span { background: transparent; }
.opened .chat-media-marker .ui-icon { color: var(--media-marker); fill: currentColor; }
.chat-view-once-card.outgoing .chat-media-marker { flex-basis: 22px; width: 22px; height: 20px; }
.chat-media-marker > svg { width: 22px; height: 20px; fill: currentColor; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.opened .chat-media-marker > svg { fill: none; }
.chat-message.ephemeral .chat-bubble > time { display: block; padding: 4px; }
.chat-message.ephemeral .chat-message-menu-button { right: -23px; }
.chat-message.mine.ephemeral .chat-message-menu-button { right: auto; left: -23px; }
.chat-history-choice { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px; margin: 0 0 10px; border: 2px solid transparent; border-radius: 18px; background: color-mix(in srgb, var(--peach) 16%, transparent); color: var(--ink); text-align: left; cursor: pointer; }
.chat-history-choice.selected { border-color: var(--dark-teal); background: color-mix(in srgb, var(--peach) 34%, transparent); }
.chat-history-choice > i { flex: 0 0 38px; height: 38px; border-radius: 12px; background: var(--white); color: var(--dark-teal); display: grid; place-items: center; }
.chat-history-choice > i .ui-icon { width: 19px; height: 19px; }
.chat-history-choice > span:nth-child(2) { display: grid; gap: 3px; flex: 1; }
.chat-history-choice strong { font-size: 16px; }
.chat-history-choice small { font-size: 12px; color: var(--muted); }
.chat-choice-check { flex: 0 0 22px; height: 22px; border: 2px solid var(--muted); border-radius: 50%; }
.selected .chat-choice-check { border-color: var(--dark-teal); background: var(--dark-teal); color: var(--white); }
.chat-choice-check .ui-icon { width: 18px; height: 18px; }
.chat-history-choice:disabled { opacity: .55; cursor: default; }
.chat-history-setting p:empty { display: none; }
.chat-saved-label { display: block; padding-top: 5px; font-size: 11px; opacity: .8; }
.chat-media-viewer [data-pause-ephemeral] { left: 14px; right: auto; font-size: 18px; }
.chat-media-viewer [data-pause-ephemeral] .ui-icon { width: 22px; height: 22px; }
.chat-ephemeral-progress { position: absolute; top: calc(65px + env(safe-area-inset-top)); left: 14px; width: calc(100% - 28px); height: 3px; z-index: 3; accent-color: #fff; border: 0; background: #ffffff50; }
.chat-ephemeral-progress::-webkit-progress-bar { background: #ffffff50; }
.chat-ephemeral-progress::-webkit-progress-value { background: #fff; }
.chat-ephemeral-progress::-moz-progress-bar { background: #fff; }
.chat-media-viewer [hidden] { display: none; }

/* Native rhythm: grouped messages 2pt, new sequences 10pt; reaction footer 4pt. */
.chat-timeline { gap: 0; }
.chat-timeline > .chat-message { margin-top: 2px; row-gap: 4px; }
.chat-timeline > .chat-message.starts-sequence { margin-top: 10px; }
.chat-timeline > .chat-message:first-child { margin-top: 0; }
.chat-message-meta:empty { display: none; }
.chat-message-meta { font-size: 12px; line-height: 1.2; }
.chat-reaction-summary { align-items: center; justify-content: center; gap: 3px; min-height: 25px; margin: 0 4px; padding: 0 7px; color: var(--muted); font: 600 11px/1 var(--chat-appearance-font); box-shadow: none; }
.chat-reaction-cluster { display: flex; align-items: center; }
.chat-reaction-cluster > span { flex: none; padding: 3px 4px; font: 400 13px/1 "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.chat-reaction-cluster > span + span { margin-left: -4px; }
.chat-reaction-count { font-size: 11px; line-height: 1; }
.chat-reaction-summary.has-own-reaction { border-width: 1.5px; border-color: var(--chat-appearance-color); color: var(--chat-appearance-color); }
.chat-read-receipt { padding-top: 0; padding-bottom: 0; }
.chat-list { gap: 12px; }
/* Include the existing 3px border in iOS's 16×12 card content inset. */
.chat-row-main { grid-template-columns: 60px minmax(0, 1fr) auto; padding: 9px 13px; }
.chat-row .chat-avatar-wrap, .chat-row .chat-avatar { width: 60px; height: 60px; }
.chat-row-copy { gap: 6px; }
.chat-row-trailing { min-height: 60px; }

/* Native keeps sent times outside normal row flow; expose them in actions. */
.chat-message.sent .chat-bubble > time { display: none; }
.chat-action-time { color: var(--muted); font-size: 11px; text-align: center; }

:root[data-theme="dark"] .chat-message-actions button.danger { color: #ff8d9b; }
:root[data-theme="dark"] .chat-message-actions hr { border-color: rgba(245,251,251,.12); }

/* Small native-sized controls keep their look but get a 44 px hit area.
   (The hover-only ⋯ button stays small: touch opens actions with a long press.) */
.chat-reaction-summary, .chat-read-receipt { position: relative; }
.chat-reaction-summary::after, .chat-read-receipt::after { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: 44px; transform: translate(-50%, -50%); }
.chat-read-receipt { min-height: 24px; padding: 2px 8px; }

/* Day and gap separators (Today · Yesterday · Mon · Sep 7). */
.chat-day-separator { align-self: center; margin: 14px 0 6px; color: var(--muted); font-size: 11px; line-height: 1.3; text-align: center; }
.chat-day-separator strong { font-weight: 700; }
.chat-timeline > .chat-day-separator:first-child { margin-top: 2px; }
.chat-timeline > .chat-day-separator + .chat-message { margin-top: 4px; }

/* Swipe left across the timeline to reveal send times; rows spring back. */
.chat-timeline { touch-action: pan-y; }
.chat-timeline.is-revealing-times > .chat-message, .chat-timeline.is-revealing-times > .chat-call-history { transform: translateX(calc(-1 * var(--chat-time-reveal, 0px))); }
.chat-timeline.is-settling > .chat-message, .chat-timeline.is-settling > .chat-call-history { transition: transform .28s cubic-bezier(.34, 1.3, .5, 1); }
.chat-reveal-time { position: absolute; left: calc(100% + 8px); top: 50%; width: 78px; overflow: hidden; color: var(--muted); font: 400 10px/1.2 var(--chat-appearance-font, var(--app-font)); white-space: nowrap; text-overflow: ellipsis; opacity: 0; pointer-events: none; transform: translateY(-50%); }
.chat-timeline.is-revealing-times .chat-reveal-time { opacity: var(--chat-time-reveal-opacity, 0); }
.chat-timeline.is-settling .chat-reveal-time { transition: opacity .2s ease-out; }
@media (prefers-reduced-motion: reduce) { .chat-timeline.is-settling > * { transition: none; } }

/* Links and messages from a newer app version. */
.chat-bubble p a { color: inherit; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; -webkit-touch-callout: default; }
.chat-system-message.unsupported span { padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 7%, transparent); }

/* Voice message bubble (ChatVoiceMessageBubble): play, scrub, time, speed. */
.chat-audio-message { min-width: min(64vw, 238px); display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-rows: auto auto; align-items: center; gap: 0 6px; padding: 2px 0; }
.chat-audio-message.unavailable { display: block; }
.chat-voice-toggle, .chat-voice-speed { min-width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; }
.chat-voice-toggle { grid-row: 1 / 3; background: color-mix(in srgb, currentColor 14%, transparent); }
.chat-voice-toggle .ui-icon { width: 18px; height: 18px; }
.chat-audio-message [data-voice-seek] { grid-column: 2; min-width: 0; width: 100%; height: 22px; margin: 0; accent-color: currentColor; }
.chat-audio-message .chat-voice-clock { grid-column: 2; font-size: 11px; font-variant-numeric: tabular-nums; opacity: .8; }
.chat-voice-speed { grid-column: 3; grid-row: 1 / 3; min-width: 44px; border-radius: 999px; font: 700 12px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.chat-message.theirs .chat-voice-clock { color: var(--muted); }
.chat-voice-player .chat-voice-clock { flex: 0 0 auto; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chat-voice-inline .chat-voice-player button { flex: 0 0 44px; width: 44px; height: 44px; margin: -6px 0; border: 0; background: transparent; color: var(--ink); }
.chat-voice-inline .chat-voice-player .chat-voice-speed { width: auto; min-width: 44px; font: 700 12px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.chat-voice-hint.is-danger { color: #d62c45; font-weight: 700; }

/* Media viewer: drag-to-dismiss, zoom and a still under loading media. */
.chat-media-viewer { background: rgb(5 9 20 / var(--chat-viewer-backdrop, 1)); overflow: hidden; }
.chat-media-viewer::backdrop { opacity: var(--chat-viewer-backdrop, 1); }
.chat-viewer-stage { position: absolute; inset: max(56px, calc(env(safe-area-inset-top) + 56px)) 0 max(80px, calc(env(safe-area-inset-bottom) + 80px)); touch-action: none; user-select: none; -webkit-user-select: none; }
.chat-viewer-media { position: absolute; inset: 0; display: grid; place-items: center; transform-origin: 50% 50%; will-change: transform; }
/* The media box hugs the picture, so the drag-to-dismiss corners round the picture itself. */
.chat-media-viewer .chat-viewer-media > img, .chat-media-viewer .chat-viewer-media > video { grid-area: 1 / 1; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; background: transparent; border-radius: var(--chat-viewer-radius, 0); }
.chat-media-viewer .chat-viewer-media > .chat-viewer-placeholder { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; }
.chat-media-viewer .chat-viewer-media > video { width: 100%; height: 100%; }
.chat-media-viewer.is-loading .chat-viewer-media > video { opacity: 0; }
.chat-media-viewer.is-dragging [data-close-media], .chat-media-viewer.is-dragging .chat-viewer-actions, .chat-media-viewer.is-dragging > p { opacity: 0; transition: opacity .12s ease; }
.chat-media-viewer.is-zoomed .chat-viewer-actions, .chat-media-viewer.is-zoomed > p { opacity: 0; pointer-events: none; }
.chat-media-viewer > p { position: absolute; left: 12px; right: 12px; bottom: max(64px, calc(env(safe-area-inset-bottom) + 64px)); margin: 0; }
.chat-media-viewer [data-close-media] .ui-icon { width: 20px; height: 20px; }
.chat-media-viewer [data-close-media] { display: grid; place-items: center; padding: 0; }

/* A photo, video or sticker on its own fills its bubble like iOS. */
.chat-message.media-only .chat-bubble { padding: 0; }
.chat-message.media-only .chat-message-media { margin: 0; }
.chat-message.media-only .chat-message-media.sticker { margin: 0; }
:root[data-theme="dark"] .chat-message.theirs .chat-bubble a { color: #8fe3e6; }
/* Interactive edge swipe-back from the room (app.js installEdgeSwipeBack): the
   list shows through underneath while the room follows the finger. */
.chat-shell.chat-swipe-reveal { position: relative; }
.chat-shell.chat-swipe-reveal > .chat-list-screen.hidden { display: block !important; position: absolute; inset: 0 0 auto; z-index: 0; max-height: 100%; overflow: hidden; pointer-events: none; }
.chat-room-screen.swipe-tracking, .chat-room-screen.swipe-settling { position: relative; z-index: 1; transform: translateX(var(--swipe-x, 0px)); background: var(--aqua); box-shadow: -10px 0 28px rgba(0,0,0,.22); }
.chat-room-screen.swipe-settling { transition: transform .24s cubic-bezier(.2,.8,.2,1); }
/* Honest note on view-once media: iOS reports screenshots, the web can't detect them. */
.chat-capture-note { position: absolute; z-index: 3; top: calc(74px + env(safe-area-inset-top)); left: 14px; right: 14px; color: rgba(255,255,255,.72); font: 500 .72rem/1.3 system-ui, sans-serif; text-align: center; text-shadow: 0 1px 2px rgba(0,0,0,.6); pointer-events: none; }
.chat-capture-note[hidden] { display: none; }

/* Full-screen camera and review (iOS): the header floats over the preview and
   only Cancel stays, as a pill like the camera's own buttons (camera.css holds
   the preview and capture bar). */
.chat-sheet.is-capturing .chat-media-form, .chat-sheet.is-capturing .memento-form { position: relative; padding: 0; }
.chat-sheet.is-capturing .chat-media-form > header, .chat-sheet.is-capturing .memento-form > header { position: absolute; z-index: 6; top: 0; left: 0; right: 0; display: flex; padding: max(10px, env(safe-area-inset-top)) 18px 0; background: none; pointer-events: none; }
.chat-sheet.is-capturing .chat-media-form > header > :not(:first-child), .chat-sheet.is-capturing .memento-form > header > :not(:first-child) { display: none; }
.chat-sheet.is-capturing .chat-media-form > header > button:first-child, .chat-sheet.is-capturing .memento-form > header > button:first-child { pointer-events: auto; min-height: 46px; padding: 0 16px; border: 0; border-radius: 23px; background: rgba(0,0,0,.52); color: #fff; font-weight: 700; }
/* The review keeps the photo edge to edge; its controls clear the status bar and home indicator. */
.chat-camera-sheet:has(.review-stage) .chat-media-form { padding: 0; }
.chat-camera-sheet:has(.review-stage) .chat-photo-tools { top: max(12px, env(safe-area-inset-top)); left: 14px; right: 14px; }
.chat-camera-sheet:has(.review-stage) .chat-review-tools { top: calc(max(12px, env(safe-area-inset-top)) + 56px); right: 14px; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 84px); }
.chat-camera-sheet:has(.review-stage) .review-duration { top: calc(max(12px, env(safe-area-inset-top)) + 8px); }
.chat-camera-sheet:has(.review-stage) .chat-media-option { left: 18px; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 12px); }
.chat-camera-sheet:has(.review-stage) .chat-media-review-actions { right: 18px; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 8px); }
.chat-camera-sheet:has(.review-stage) .chat-media-send-count { right: 90px; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 22px); }
.chat-camera-sheet:has(.review-stage) .chat-media-status { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 76px); }
.chat-camera-sheet:has(.review-stage) .chat-media-progress { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 74px); }
.chat-camera-sheet:has(.review-stage) [data-cancel-chat-upload] { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 92px); }
