:root {
  font:
    100%/1.45 Roboto,
    system-ui,
    sans-serif;
  color: #22334d;
  background: #f5f2eb;
  --canvas: #f5f2eb;
  --chrome: #fffefa;
  --list: #e9e4da;
  --ink: #22334d;
  --muted: #606a75;
  --navy: #253b5b;
  --line: #e2e1da;
  --accent: #935b2b;
  --received: white;
  --sent-ink: #fffdf9;
  --sent-muted: #c4cedc;
  --input: #f0f1ee;
  --avatar: #ead6bf;
  --bubble-radius: 19px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
textarea,
input,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  background: var(--input);
  padding: 0.57rem 0.85rem;
  min-height: 44px;
}
button:disabled {
  cursor: default;
  opacity: 0.65;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 1.5rem;
}
h2 {
  font-size: 1.2rem;
}
textarea,
input,
select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--received);
  padding: 0.7rem;
}
small,
time {
  font-size: 0.8rem;
  color: var(--muted);
}
[hidden] {
  display: none !important;
}
#gate {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  gap: 1rem;
  padding: 2rem;
}
.brand-mark {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 18px;
}
#gate h1,
.wordmark {
  letter-spacing: -0.05em;
}
#login,
#send,
.primary {
  background: var(--navy);
  color: var(--sent-ink);
}
#setup {
  max-width: 26rem;
  color: var(--muted);
}
#shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 9rem minmax(16rem, 23rem) minmax(0, 1fr);
  overflow: hidden;
}
.wordmark {
  font-size: 1.5rem;
  padding: 1.15rem 0.55rem;
}
nav {
  padding: 0.3rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: var(--chrome);
  border-right: 1px solid var(--line);
}
nav button {
  text-align: left;
  background: none;
}
nav button[aria-current="page"] {
  background: var(--list);
  font-weight: 650;
}
header {
  padding: 0.85rem 1rem;
  min-height: 4rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-bottom: 1px solid var(--line);
  background: var(--chrome);
}
#list header {
  justify-content: space-between;
}
header button {
  background: none;
  font-size: 1.35rem;
}
#list {
  position: relative;
  background: var(--list);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#chat-search {
  margin: 0.75rem 0.75rem 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--chrome);
  color: var(--ink);
  font: inherit;
}
#new-chat {
  position: absolute;
  inset-inline-end: 1rem;
  bottom: 1rem;
  border-radius: 50%;
  width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  font-size: 1.65rem;
  background: var(--accent);
  color: var(--chrome);
}
.cards {
  padding: 0.75rem;
  padding-bottom: 5.25rem;
  overflow: auto;
}
.card {
  width: 100%;
  text-align: left;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  background: var(--chrome);
  border: 1px solid transparent;
  padding: 0.8rem;
  margin-bottom: 0.625rem;
  border-radius: 16px;
}
.card[aria-current="true"] {
  border-color: var(--accent);
}
.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  width: 2.6rem;
  height: 2.6rem;
  object-fit: cover;
  flex: none;
  background: var(--avatar);
  color: var(--ink);
  font-weight: 650;
}
.details {
  display: grid;
  min-width: 0;
  flex: 1;
}
.details > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge {
  background: var(--navy);
  color: var(--sent-ink);
  padding: 0.1rem 0.45rem;
  border-radius: 1rem;
}
#thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
#back {
  display: none;
}
#timeline {
  overflow: auto;
  flex: 1;
  padding: 1rem max(1rem, calc((100% - 48rem) / 2));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7rem;
}
.bubble {
  touch-action: pan-y pinch-zoom;
  border-radius: var(--bubble-radius);
  background: var(--received);
  border: 1px solid var(--line);
  min-width: 6rem;
  max-width: min(88%, 36rem);
  padding: 0.6rem 0.8rem;
  overflow-wrap: anywhere;
  flex: none;
}
.bubble.mine {
  background: var(--navy);
  color: var(--sent-ink);
  align-self: flex-end;
}
.bubble p {
  white-space: pre-wrap;
}
.bubble time,
.bubble .meta {
  display: block;
  font-size: 0.8rem;
}
.mine time,
.mine .meta {
  color: var(--sent-muted);
}
.bubble .who {
  font-size: 0.85rem;
  font-weight: 650;
}
.meta {
  color: var(--accent);
}
.bubble .actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.actions button {
  font-size: 1rem;
  color: inherit;
  background: none;
  min-height: 30px;
  padding: 0 0.3rem;
}
.excerpt {
  display: block;
  width: 100%;
  text-align: left;
  border-radius: 5px;
  border-inline-start: 3px solid var(--accent);
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.35rem;
  background: var(--canvas);
}
.mine .excerpt {
  color: var(--ink);
}
.excerpt span {
  display: block;
  font-size: 0.87rem;
}
.lit {
  outline: 3px solid var(--accent);
}
.reaction {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 99px;
  background: var(--chrome);
  color: var(--ink);
  font-size: 0.86rem;
}
.empty {
  margin: auto;
  color: var(--muted);
  text-align: center;
  padding: 1.2rem;
}
#composer {
  padding: 0.65rem max(0.75rem, calc((100% - 48rem) / 2));
  background: var(--chrome);
  border-top: 1px solid var(--line);
}
.entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.entry textarea {
  flex: 1;
  resize: none;
  border-radius: 22px;
}
#mic {
  touch-action: none;
  user-select: none;
}
#quote,
#recording {
  padding: 0.4rem;
  color: var(--accent);
}
#panel {
  grid-column: 2/4;
  overflow: auto;
  background: var(--chrome);
  padding: clamp(1rem, 4vw, 3rem);
}
.stack {
  display: grid;
  gap: 0.85rem;
  max-width: 45rem;
}
.stack label {
  display: grid;
  gap: 0.3rem;
}
.stack button {
  justify-self: start;
}
.stack textarea {
  width: 100%;
}
dialog {
  color: var(--ink);
  width: min(26rem, 94vw);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.2rem;
  background: var(--chrome);
}
dialog::backdrop {
  background: #17263c70;
}
dialog button {
  margin: 0.2rem;
}
#dialog-body {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}
#notice {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: var(--sent-ink);
  border-radius: 12px;
  padding: 0.65rem 1rem;
  max-width: 90vw;
  z-index: 4;
}
@media (max-width: 740px) {
  #shell {
    display: flex;
    flex-direction: column;
  }
  nav {
    order: 2;
    flex-direction: row;
    justify-content: space-around;
    padding: 0.3rem 0.1rem max(0.3rem, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
  }
  nav button {
    font-size: 0.9rem;
    text-align: center;
  }
  .wordmark {
    display: none;
  }
  #list,
  #thread,
  #panel {
    flex: 1;
    min-height: 0;
  }
  #shell[data-view="home"] #thread,
  #shell[data-view="thread"] #list,
  #shell[data-view="thread"] nav {
    display: none;
  }
  #back {
    display: block;
  }
  #composer {
    padding-bottom: max(0.65rem, env(safe-area-inset-bottom));
  }
  .bubble {
    max-width: 88%;
  }
  header {
    padding-top: max(0.75rem, env(safe-area-inset-top));
  }
}
.photo {
  display: block;
  width: 100%;
  height: auto;
  max-height: 66dvh;
  object-fit: contain;
}
audio {
  max-width: 100%;
}
#recording button {
  margin-left: 0.4rem;
}
nav button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.nav-icon {
  font-size: 1.35rem;
  line-height: 1;
}
#thread header h2 {
  flex: 1;
}
@media (max-width: 740px) {
  nav button {
    flex-direction: column;
    gap: 0.15rem;
    justify-content: center;
  }
}
.excerpt span,
#quote span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.details small {
  min-width: 0;
}

.chat-day {
  align-self: center;
  padding: .2em .85em;
  border-radius: 1em;
  background: var(--chrome);
  color: var(--muted);
  text-transform: capitalize;
}
.original { margin-block: .3em; }
.original summary { cursor: pointer; font-size: .85em; }
.original > span { display: block; margin-block-start: .35em; white-space: pre-wrap; }
.voice-control audio { max-width: 100%; }
.plan-card, .recovery-preference {
  display: grid;
  gap: .45rem;
  padding: 1rem;
  background: var(--chrome);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.plan-card .ads-preference, .recovery-preference .ads-preference {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  border-top: 1px solid var(--line);
}
.ads-preference input {
  width: 1.2em;
  height: 1.2em;
  accent-color: var(--navy);
}
.analysis-workspace, .result-content, .result-content section, .history-record {
  display: grid;
  gap: .65rem;
}
.result-tabs { display: flex; flex-wrap: wrap; gap: .4rem; }
.result-tabs [aria-pressed="true"] { background: var(--navy); color: white; }
.result-content section, .history-record {
  padding: .9rem;
  background: var(--chrome);
  border: 1px solid var(--line);
  border-radius: .85rem;
}
.result-content ul { margin: 0; padding-inline-start: 1.3em; }
.stack .history-record {
  width: 100%; justify-self: stretch; text-align: start;
  grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
}
.history-list { display: grid; gap: .65rem; }
.history-range label { display: inline-grid; margin-inline-end: .75rem; }
.history-range summary { cursor: pointer; }
.history-icon { font-size: 1.35em; }
.history-details { min-width: 0; display: grid; gap: .25em; }
.history-details strong { overflow-wrap: anywhere; }
.history-details small { color: var(--muted); }
.history-excerpt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-severity { border-radius: 1em; padding: .2em .55em; color: var(--ink); background: var(--list); }
.history-severity[data-level="high"] { color: #822323; background: #ffeded; }
.history-severity[data-level="medium"] { color: #784710; background: #fff1d4; }
.history-severity[data-level="none"], .history-severity[data-level="low"] { color: #265438; background: #e1f5e7; }

/* FR-501-E/F/H. Android ChatAppearanceTokens, scoped to chat and its live preview. */
[data-chat-style="Nightfall"] {
  --canvas: #101e31; --chrome: #142338; --list: #101e31; --ink: #f0f2f5; --muted: #a7b5c6;
  --navy: #eee4d3; --line: #34435a; --accent: #e4b27e; --received: #24344c;
  --sent-ink: #1c2c43; --sent-muted: #5d6875; --input: #24344a; --avatar: #3d4b60; --bubble-radius: 17px;
}
[data-chat-style="Rosewater"] {
  --canvas: #fbf1ee; --chrome: #fff9f5; --list: #f0dfe1; --ink: #49383e; --muted: #6f5960;
  --navy: #ebc8cf; --line: #e4ccd2; --accent: #8a4158; --received: #fffcf9;
  --sent-ink: #49323b; --sent-muted: #674951; --input: #f2e4e5; --avatar: #e6b9c4;
}
[data-chat-style] { color: var(--ink); }
[data-chat-size="small"] { font-size: .875rem; }
[data-chat-size="medium"] { font-size: 1rem; }
[data-chat-size="large"] { font-size: 1.125rem; }
#thread, .appearance-preview { background: var(--canvas); }
[data-chat-style] h2 { font-size: 1.2em; }
[data-chat-style] :is(small, time, .bubble .meta) { font-size: .8em; }
[data-chat-style] .bubble .who, [data-chat-style] .excerpt span { font-size: .875em; }
.appearance-preview { display: flex; flex-direction: column; gap: .6em; padding: .75em; border-radius: 16px; }
#dialog-body label:has(select) { display: grid; gap: .25em; }
.group-info, .group-page { display: grid; gap: .6em; }
.group-info details { border-block-start: 1px solid var(--line); padding-block: .5em; }
.group-info summary { cursor: pointer; padding-block: .45em; }
.group-page label { display: grid; gap: .25em; }
.group-page label:has([type=checkbox]) { display: flex; justify-content: space-between; }
.group-member { display: grid; align-items: center; grid-template-columns: auto 1fr auto; gap: .5em; }
.group-controls { grid-column: 2 / -1; display: flex; flex-wrap: wrap; }
.group-page button .avatar { vertical-align: middle; margin-inline-end: .5em; }

.group-page .group-choice { display: flex; align-items: center; gap: .65em; min-height: 44px; }
.group-choice input { margin-inline-start: auto; accent-color: var(--accent); }
.identity-card { display: grid; align-items: center; grid-template-columns: auto minmax(0, 1fr) auto; gap: .65em; }
.identity-card strong { overflow-wrap: anywhere; }
.import-page { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.import-page strong { min-width: 0; overflow-wrap: anywhere; }
.import-page button { flex-shrink: 0; }
.summary-export {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}
.summary-export a { display: inline-block; padding: .5rem; }
.bubble a { color: inherit; text-decoration: underline; overflow-wrap: anywhere; }
.play-link { margin-inline: .3em; }
dialog:has(.provider-video) { width: min(44rem,94vw); }
.provider-video { width: 100%; aspect-ratio: 16/9; min-height: 200px; border: 0; }
button.photo-viewer, button.photo-tile {
  display: block; padding: 0; margin: 0; max-width: 100%; overflow: hidden;
}
button.photo-viewer { width: 100%; touch-action: none; user-select: none; cursor: zoom-in; }
.photo-viewer[aria-pressed="true"] { cursor: grab; }
.photo-tile .photo { width: auto; max-width: 100%; max-height: 16rem; }
button.photo-tile:empty, button.photo-tile:not(:has(img)) { padding-inline: .6rem; }
.delivery-tick { color: var(--sent-muted); font-size: .8em; }
.delivery-tick.read { color: #a6d9ff; }
:is([data-chat-style="Nightfall"], [data-chat-style="Rosewater"]) .delivery-tick.read { color: #125787; }
.delivery-tick.failed { color: #ffc5b6; }
:is([data-chat-style="Nightfall"], [data-chat-style="Rosewater"]) .delivery-tick.failed { color: #922f23; }
.public-share { display: grid; justify-items: start; gap: .4rem; }
.public-share input { width: 100%; }
.public-share blockquote { margin: .4rem 0; border-inline-start: .2rem solid var(--line); padding-inline-start: .8rem; }
.sent-invites .result-tabs { flex-wrap: wrap; }
.invite-card { display: flex; align-items: center; flex-wrap: wrap; gap: .5em; padding: .6em 0; border-bottom: 1px solid var(--line); }
.invite-card small { width: 100%; }

#welcome { width: min(100%, 32rem); }
.welcome-pane, #sign-in { display: grid; gap: 1rem; }
.welcome-pane { text-align: start; }
.welcome-pane h2, .welcome-pane p { margin: 0; }
.welcome-pane details p { margin-block-end: .8rem; }
.welcome-links, .agreement, .language-grid label { display: flex; align-items: center; gap: .65rem; }
.welcome-links { flex-wrap: wrap; }
.language-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; border: 0; padding: 0; }
.language-grid legend { font-size: 1.25rem; font-weight: bold; padding-block-end: 1rem; }
.language-grid label { border: 1px solid var(--line); padding: .6rem; border-radius: .6rem; cursor: pointer; }
.language-grid label:has(:checked) { outline: 2px solid var(--navy); }
.language-grid small { display: block; }
.voice-cues { display: flex; flex-wrap: wrap; gap: .4rem .9rem; align-items: center; font-weight: 600; color: var(--ink); }
.voice-cues span { background: var(--input); border-radius: .65rem; padding: .3rem .6rem; }
@media (prefers-reduced-motion: no-preference) {
  .voice-cues { animation: voice-cue-in .18s ease-out; }
  @keyframes voice-cue-in { from { opacity: 0; transform: translateY(.35rem); } }
}

.legal-notices { max-width: 64rem; margin: auto; padding: 1.5rem; }
.legal-notices details { padding-block: .75rem; border-bottom: 1px solid var(--line); }
.legal-notices summary { cursor: pointer; }
.legal-notices pre { white-space: pre-wrap; overflow-wrap: anywhere; }
nav button:has(.rail-unread) { position: relative; }
.rail-unread { position: absolute; inset-block-start: 0; inset-inline-end: .15rem; }
.chat-activity { display: grid; justify-items: end; gap: .25rem; }
@media (max-width: 740px) {
  dialog:has(.contact-search) { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; }
}
