:root {
  --ink: #17171c;
  --ink-soft: #34333a;
  --muted: #85848d;
  --paper: #f4f4f6;
  --surface: #fff;
  --surface-soft: #f8f8fa;
  --line: #e9e9ed;
  --line-strong: #dcdce2;
  --accent: #fe315b;
  --accent-dark: #e7234b;
  --accent-soft: #ffe1e8;
  --accent-faint: #fff3f6;
  --success: #22a06b;
  --success-soft: #eaf8f1;
  --warning: #9a6b17;
  --warning-soft: #fff6dc;
  --danger: #d9364f;
  --shadow-card: 0 20px 60px rgb(24 24 32 / 8%);
  --shadow-float: 0 14px 36px rgb(16 16 24 / 14%);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
  background:
    radial-gradient(circle at 0 0, rgb(254 49 91 / 6%), transparent 28rem),
    radial-gradient(circle at 100% 15%, rgb(74 225 213 / 5%), transparent 30rem),
    var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: transparent;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
label[for="archive-input"],
.mobile-toolbar a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
label[for="archive-input"]:focus-visible,
.mobile-toolbar a:focus-visible,
.chat-menu-button:focus-visible,
.drawer-close:focus-visible {
  outline: 3px solid rgb(254 49 91 / 24%);
  outline-offset: 2px;
}

code {
  padding: 0.15em 0.42em;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink-soft);
  background: #f7f7f9;
  font-size: 0.9em;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 12px;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: 10px;
  color: #fff;
  background: #111116;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1380px, 100%);
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) 18px max(28px, env(safe-area-inset-left));
}

.brand,
.header-actions,
.inline-actions,
.storage-heading,
.signature-card,
.dialog-heading,
.result-heading {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  display: block;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 9px 24px rgb(17 17 22 / 18%);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand h1,
.brand p,
.archive-heading h2,
.archive-heading p,
.dialog-heading h2,
.dialog-heading p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.header-actions {
  gap: 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.status-pill,
.mini-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  font-weight: 700;
}

.status-pill {
  gap: 7px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid #d4efe1;
  color: var(--success);
  background: var(--success-soft);
  font-size: 11px;
}

.status-pill::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgb(34 160 107 / 10%);
  content: "";
}

.status-pill.is-offline {
  border-color: #f0dfb4;
  color: var(--warning);
  background: var(--warning-soft);
}

.mini-pill {
  padding: 5px 9px;
  color: #74737b;
  background: #f0f0f2;
  font-size: 10px;
}

.mini-pill.good {
  color: var(--success);
  background: var(--success-soft);
}

.mini-pill.warn {
  color: var(--warning);
  background: var(--warning-soft);
}

main {
  width: min(1380px, 100%);
  margin: 0 auto;
  padding: 20px max(28px, env(safe-area-inset-right)) calc(44px + env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
}

.import-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.72fr);
  gap: 20px;
  width: min(1040px, 100%);
  margin: clamp(10px, 4vh, 56px) auto 0;
}

.hero-card,
.privacy-card,
.conversation-panel,
.message-panel {
  border: 1px solid rgb(23 23 28 / 6%);
  background: rgb(255 255 255 / 93%);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.hero-card,
.privacy-card {
  border-radius: var(--radius-xl);
}

.hero-card {
  position: relative;
  padding: clamp(34px, 5vw, 60px);
  overflow: hidden;
}

.hero-card::before {
  position: absolute;
  top: -110px;
  right: -90px;
  width: 270px;
  height: 270px;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(254 49 91 / 16%), rgb(254 49 91 / 0) 68%);
  content: "";
  pointer-events: none;
}

.hero-card > * {
  position: relative;
}

.hero-card h2 {
  max-width: 650px;
  margin: 0;
  color: #111116;
  font-size: clamp(38px, 5vw, 58px);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 1.08;
}

.hero-copy {
  max-width: 650px;
  margin: 20px 0 28px;
  color: #6f6e76;
  font-size: 15px;
  line-height: 1.8;
}

.privacy-card {
  align-self: start;
  padding: 30px;
}

.privacy-card h2 {
  margin: 0 0 21px;
  font-size: 19px;
  font-weight: 750;
}

.check-list {
  display: grid;
  gap: 13px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  position: relative;
  padding-left: 27px;
  color: #56555e;
  font-size: 13px;
  line-height: 1.58;
}

.check-list li::before {
  position: absolute;
  top: 1px;
  left: 0;
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--success);
  content: "✓";
  font-size: 10px;
  font-weight: 850;
}

.drop-zone {
  display: grid;
  justify-items: center;
  padding: 28px 24px 24px;
  border: 1.5px dashed #d8c3ca;
  border-radius: 20px;
  text-align: center;
  background: linear-gradient(155deg, #fff8fa, #faf9fb);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.drop-zone.is-dragging {
  transform: translateY(-2px) scale(1.005);
  border-color: var(--accent);
  background: var(--accent-faint);
  box-shadow: 0 12px 30px rgb(254 49 91 / 10%);
}

.drop-illustration {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 15px;
  place-items: center;
  border-radius: 19px;
  color: var(--accent);
  background: var(--accent-soft);
}

.drop-illustration svg {
  width: 31px;
  height: 31px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
}

.drop-zone p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.drop-zone .file-summary {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  font-weight: 700;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
  text-decoration: none;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: scale(0.985);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.button-primary {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 10px 24px rgb(254 49 91 / 22%);
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.button-secondary {
  border-color: var(--line-strong);
  color: var(--ink-soft);
  background: #fff;
}

.button-secondary:hover:not(:disabled) {
  border-color: #cfcfd6;
  background: #f8f8fa;
}

.button-quiet {
  color: #73727a;
  background: transparent;
}

.button-quiet:hover:not(:disabled) {
  color: var(--ink);
  background: #f0f0f2;
}

.button-wide {
  width: 100%;
}

.danger {
  color: var(--danger);
}

.open-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.filter-bar label:not(.search-field),
.conversation-panel > label {
  color: #65646c;
  font-size: 11px;
  font-weight: 700;
}

.filter-bar input,
.filter-bar select,
.conversation-panel select {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  appearance: none;
}

.filter-bar select,
.conversation-panel select {
  padding-right: 32px;
  background-image:
    linear-gradient(45deg, transparent 50%, #777780 50%),
    linear-gradient(135deg, #777780 50%, transparent 50%);
  background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

.search-field {
  position: relative;
}

.search-field::before {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 13px;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  border: 1.8px solid #8c8b94;
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.search-field::after {
  position: absolute;
  z-index: 1;
  top: calc(50% + 5px);
  left: 25px;
  width: 6px;
  height: 1.8px;
  transform: rotate(45deg);
  border-radius: 9px;
  background: #8c8b94;
  content: "";
  pointer-events: none;
}

.search-field input {
  padding-left: 37px;
  background: #f1f1f3;
}

.notice,
.progress-panel {
  margin-top: 18px;
  padding: 15px;
  border-radius: var(--radius-sm);
}

.notice {
  border: 1px solid #f0dfb6;
  color: #675426;
  background: var(--warning-soft);
  font-size: 13px;
  line-height: 1.6;
}

.notice p {
  margin: 5px 0 0;
}

.notice-error {
  border-color: #f0c4cc;
  color: #8b293d;
  background: #fff0f3;
}

.inline-actions {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.progress-panel {
  display: flex;
  align-items: center;
  gap: 13px;
  border: 1px solid #eadce1;
  background: #fff7f9;
}

.progress-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid #f5ccd5;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.storage-panel {
  margin-top: 27px;
  padding-top: 23px;
  border-top: 1px solid var(--line);
}

.storage-heading {
  justify-content: space-between;
  gap: 14px;
}

.storage-heading h3 {
  margin: 0;
  font-size: 14px;
}

.storage-panel > p {
  margin: 11px 0;
  color: #68676f;
  font-size: 12px;
  line-height: 1.58;
}

.meter {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #ededf0;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #31b47d, #55d8a4);
  transition: width 250ms ease;
}

.muted {
  color: var(--muted);
}

.viewer {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 16px;
  min-height: calc(100vh - 142px);
}

.conversation-panel,
.message-panel {
  border-radius: var(--radius-lg);
}

.conversation-panel {
  position: sticky;
  top: 16px;
  align-self: start;
  padding: 24px;
}

.archive-heading h2 {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.archive-heading .muted {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.5;
}

.archive-heading-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.conversation-avatar {
  display: grid;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  overflow: hidden;
  place-items: center;
  border-radius: 50%;
  color: #5a5862;
  background: linear-gradient(145deg, #eeeef1, #dddde2);
  box-shadow: inset 0 0 0 1px rgb(23 23 28 / 5%);
  font-size: 17px;
  font-weight: 850;
}

.conversation-panel > label {
  display: block;
  margin: 24px 0 7px;
}

#replace-archive {
  margin-top: 9px;
}

.stats-list {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 14px;
  margin: 23px 0;
  padding: 19px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.stats-list dt {
  color: var(--muted);
}

.stats-list dd {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 800;
  text-align: right;
}

.signature-card {
  align-items: flex-start;
  gap: 10px;
  padding: 13px;
  border: 1px solid #d8eee3;
  border-radius: 14px;
  color: var(--success);
  background: var(--success-soft);
}

.signature-card > span {
  display: grid;
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--success);
  font-size: 11px;
  font-weight: 900;
}

.signature-card strong {
  font-size: 11px;
}

.signature-card > div {
  min-width: 0;
}

.signature-card p {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-size: 10px;
  line-height: 1.4;
}

.message-panel {
  min-width: 0;
  padding: 18px 20px;
  background: #f5f5f7;
}

.filter-bar {
  position: sticky;
  z-index: 4;
  top: 0;
  display: grid;
  grid-template-columns: minmax(210px, 1.5fr) repeat(4, minmax(126px, 0.72fr)) auto;
  align-items: end;
  gap: 8px;
  padding: 3px 0 16px;
  background: linear-gradient(#f5f5f7 82%, rgb(245 245 247 / 0));
}

.filter-bar label:not(.search-field) {
  display: grid;
  gap: 5px;
}

.result-heading {
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 13px;
  border-bottom: 1px solid var(--line-strong);
  color: #777680;
  font-size: 11px;
}

.result-heading p {
  margin: 0;
}

.message-list {
  display: grid;
  gap: 13px;
  margin: 0;
  padding: 20px 3px 44px;
  list-style: none;
}

.message-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  width: fit-content;
  max-width: min(800px, 83%);
}

.message-item.is-self {
  grid-template-columns: minmax(0, 1fr) 40px;
  margin-left: auto;
}

.message-item.is-self .avatar {
  grid-column: 2;
}

.message-item.is-self .message-body {
  grid-row: 1;
  grid-column: 1;
  align-items: flex-end;
}

.avatar {
  display: grid;
  width: 40px;
  height: 40px;
  overflow: hidden;
  place-items: center;
  border-radius: 50%;
  color: #5a5961;
  background: #e4e4e8;
  box-shadow: 0 2px 8px rgb(20 20 28 / 8%);
  font-size: 13px;
  font-weight: 850;
}

.message-item.is-self .avatar {
  color: #9a2b42;
  background: #ffdce4;
}

.avatar img,
.conversation-avatar img,
.interaction-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 3px 5px;
  color: #96959d;
  font-size: 10px;
}

.message-meta strong {
  color: #62616a;
  font-size: 11px;
}

.bubble {
  position: relative;
  max-width: 100%;
  padding: 11px 13px;
  border: 0;
  border-radius: 5px 18px 18px;
  color: #242329;
  background: #fff;
  box-shadow: 0 3px 10px rgb(17 17 24 / 4%);
}

.message-item.is-self .bubble {
  border-radius: 18px 5px 18px 18px;
  color: #fff;
  background: #2788f5;
  box-shadow: 0 3px 10px rgb(39 136 245 / 10%);
}

.message-item.is-neutral {
  display: flex;
  width: 100%;
  max-width: none;
  justify-content: center;
  padding: 3px 0;
}

.neutral-card {
  position: relative;
  width: min(510px, 88%);
  padding: 16px;
  overflow: hidden;
  border: 1px solid rgb(23 23 28 / 6%);
  border-radius: 18px;
  color: #4f4e56;
  background: #fff;
  box-shadow: 0 8px 24px rgb(22 22 30 / 6%);
}

.neutral-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--accent), #ff8098);
  content: "";
}

.message-item.is-notice .neutral-card {
  width: auto;
  max-width: min(620px, 90%);
  padding: 6px 11px;
  border: 0;
  border-radius: 999px;
  color: #97969e;
  background: rgb(225 225 229 / 68%);
  box-shadow: none;
  text-align: center;
}

.message-item.is-notice .neutral-card::before,
.message-item.is-tombstone .neutral-card::before {
  display: none;
}

.message-item.is-tombstone .neutral-card {
  width: auto;
  min-width: 150px;
  max-width: min(430px, 90%);
  padding: 8px 13px;
  border: 0;
  border-radius: 999px;
  color: #929199;
  background: #eaeaed;
  box-shadow: none;
  text-align: center;
}

.message-item[data-actor-role="interaction_agent"] .neutral-card {
  border-color: #eee1f5;
  background: linear-gradient(145deg, #fff, #fbf5ff);
}

.message-item[data-actor-role="interaction_agent"] .neutral-card::before {
  background: linear-gradient(180deg, #a85ee3, #ff6e8b);
}

.message-item[data-interaction-kind="flame_pet"] .neutral-card {
  border-color: #ffd9c2;
  background: linear-gradient(145deg, #fffaf6, #fff0e8);
}

.message-item[data-interaction-kind="flame_pet"] .neutral-card::before {
  background: linear-gradient(180deg, #ff7a32, #ff3e67);
}

.message-item[data-interaction-kind="flame_pet"] .structured-card-label::before {
  margin-right: 4px;
  content: "🔥";
}

.message-item[data-interaction-kind="shared_savings"] .neutral-card {
  border-color: #f1e3b8;
  background: linear-gradient(145deg, #fffdf7, #fff8e7);
}

.message-item[data-interaction-kind="shared_savings"] .neutral-card::before {
  background: linear-gradient(180deg, #ffbd35, #f28a2c);
}

.message-item[data-interaction-kind="shared_savings"] .structured-card-label::before {
  margin-right: 4px;
  content: "🎯";
}

.message-item[data-interaction-kind="relationship_theme"] .neutral-card,
.message-item[data-interaction-kind="relationship"] .neutral-card,
.message-item[data-interaction-kind="chat_appearance"] .neutral-card {
  width: auto;
  max-width: min(620px, 90%);
  padding: 7px 12px;
  border: 0;
  border-radius: 999px;
  color: #929199;
  background: #eeeeF1;
  box-shadow: none;
  text-align: center;
}

.message-item[data-interaction-kind="relationship_theme"] .neutral-card::before,
.message-item[data-interaction-kind="relationship"] .neutral-card::before,
.message-item[data-interaction-kind="chat_appearance"] .neutral-card::before,
.message-item[data-interaction-kind="relationship_theme"] .structured-card-label,
.message-item[data-interaction-kind="relationship"] .structured-card-label,
.message-item[data-interaction-kind="chat_appearance"] .structured-card-label,
.message-item[data-interaction-kind="relationship_theme"] .structured-card-title,
.message-item[data-interaction-kind="relationship"] .structured-card-title,
.message-item[data-interaction-kind="chat_appearance"] .structured-card-title,
.message-item[data-interaction-kind="relationship_theme"] .structured-card-object,
.message-item[data-interaction-kind="relationship"] .structured-card-object,
.message-item[data-interaction-kind="chat_appearance"] .structured-card-object,
.message-item[data-interaction-kind="relationship_theme"] .structured-card-footer,
.message-item[data-interaction-kind="relationship"] .structured-card-footer,
.message-item[data-interaction-kind="chat_appearance"] .structured-card-footer,
.message-item[data-interaction-kind="relationship_theme"] .neutral-meta,
.message-item[data-interaction-kind="relationship"] .neutral-meta,
.message-item[data-interaction-kind="chat_appearance"] .neutral-meta {
  display: none;
}

.message-item[data-interaction-kind="relationship_theme"] .structured-card-summary,
.message-item[data-interaction-kind="relationship"] .structured-card-summary,
.message-item[data-interaction-kind="chat_appearance"] .structured-card-summary {
  color: #929199;
  font-size: 11px;
  line-height: 1.5;
}

.message-item[data-actor-role="unknown"] .neutral-card {
  width: auto;
  max-width: min(420px, 88%);
  padding: 7px 11px;
  border: 0;
  border-radius: 999px;
  color: #9998a0;
  background: #eeeeF1;
  box-shadow: none;
  text-align: center;
}

.message-item[data-actor-role="unknown"] .neutral-card::before,
.message-item[data-actor-role="unknown"] .structured-card-label,
.message-item[data-actor-role="unknown"] .structured-card-title,
.message-item[data-actor-role="unknown"] .structured-card-object,
.message-item[data-actor-role="unknown"] .structured-card-footer,
.message-item[data-actor-role="unknown"] .neutral-meta {
  display: none;
}

.message-item[data-actor-role="unknown"] .structured-card-summary {
  color: #9998a0;
  font-size: 11px;
}

.interaction-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -2px 0 12px;
  padding: 0 0 11px;
  border-bottom: 1px solid rgb(129 80 162 / 11%);
}

.interaction-avatar {
  display: grid;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  overflow: hidden;
  place-items: center;
  border-radius: 50%;
  color: #744a8e;
  background: linear-gradient(145deg, #f1e3f8, #e7d5f2);
  font-size: 12px;
  font-weight: 850;
}

.interaction-identity > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.interaction-name {
  overflow: hidden;
  color: #45384d;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.interaction-role,
.structured-card-label {
  color: #8e6b9e;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.structured-card-content {
  display: grid;
  gap: 6px;
}

.bubble-card .structured-card-content {
  min-width: min(300px, 52vw);
  margin-bottom: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgb(31 30 37 / 8%);
}

.structured-card-title {
  margin: 0;
  overflow-wrap: anywhere;
  color: #2f2e35;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.45;
}

.structured-card-summary,
.structured-card-object,
.notice-copy,
.tombstone-copy {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.structured-card-summary {
  color: #696871;
  font-size: 12px;
  line-height: 1.6;
}

.structured-card-object {
  color: #8b8a92;
  font-size: 11px;
}

.structured-card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
}

.structured-card-footer span {
  padding: 4px 8px;
  border-radius: 999px;
  color: #795b87;
  background: #f7ecfb;
  font-size: 9px;
  font-weight: 750;
}

.notice-copy,
.tombstone-copy {
  font-size: 11px;
  line-height: 1.5;
}

.tombstone-copy {
  color: #8e8d95;
  font-weight: 650;
}

.neutral-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  color: #9a99a1;
  font-size: 9px;
}

.message-item.is-notice .neutral-meta,
.message-item.is-tombstone .neutral-meta {
  margin-top: 2px;
}

.message-item.is-notice .type-badge,
.message-item.is-tombstone .type-badge {
  display: none;
}

.neutral-sender::after {
  content: " ·";
}

.message-text {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.65;
}

.reply-block {
  margin-bottom: 9px;
  padding: 8px 10px;
  border-left: 3px solid #c8c7ce;
  border-radius: 8px;
  color: #74737c;
  background: rgb(239 239 242 / 75%);
  font-size: 11px;
  line-height: 1.55;
}

.message-item.is-self .reply-block {
  border-left-color: #eca1b1;
  background: rgb(255 255 255 / 55%);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(105px, 175px));
  gap: 7px;
  margin-top: 9px;
}

.media-button {
  display: grid;
  min-height: 82px;
  overflow: hidden;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  color: var(--ink-soft);
  background: #ececef;
}

.media-button.is-image {
  min-height: 0;
  background: #e9e9ec;
}

.media-button.is-video::before {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: rgb(20 20 26 / 72%);
  content: "▶";
  font-size: 14px;
}

.media-button.is-audio {
  grid-template-columns: auto 1fr;
  min-height: 50px;
  padding-left: 13px;
  text-align: left;
}

.media-button.is-audio::before {
  color: #2788f5;
  content: "◖│││";
  font-size: 15px;
  letter-spacing: -2px;
}

.bubble-visual-media {
  padding: 0;
  overflow: hidden;
  background: transparent !important;
  box-shadow: none !important;
}

.bubble-visual-media .media-grid {
  margin: 0;
}

.media-button img,
.media-button video {
  display: block;
  width: 100%;
  max-height: 190px;
  object-fit: cover;
}

.media-button span {
  padding: 12px;
  font-size: 11px;
  font-weight: 700;
}

.type-badge {
  padding: 2px 6px;
  border-radius: 999px;
  color: #74737c;
  background: #e8e8eb;
  font-size: 9px;
  font-weight: 700;
}

.date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  color: #a09fa7;
  font-size: 10px;
}

.date-divider::before,
.date-divider::after {
  width: min(80px, 18vw);
  height: 1px;
  background: #e0e0e4;
  content: "";
}

.empty-state {
  display: grid;
  justify-items: center;
  padding: 74px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-illustration {
  display: grid;
  width: 68px;
  height: 68px;
  margin-bottom: 15px;
  place-items: center;
  border-radius: 23px;
  color: #a1a0a8;
  background: #ececef;
}

.empty-illustration svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.empty-state strong {
  color: var(--ink-soft);
  font-size: 19px;
}

.empty-state p {
  margin: 7px 0 0;
  font-size: 12px;
}

.media-dialog {
  width: min(880px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 24px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 30px 100px rgb(8 8 12 / 40%);
}

.media-dialog::backdrop {
  background: rgb(14 14 19 / 76%);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.dialog-heading {
  justify-content: space-between;
  gap: 16px;
  padding: 16px 19px;
  border-bottom: 1px solid var(--line);
}

.dialog-heading h2 {
  font-size: 18px;
}

.media-content {
  display: grid;
  min-height: 260px;
  max-height: calc(100vh - 116px);
  place-items: center;
  padding: 20px;
  overflow: auto;
  background: #111116;
}

.media-content img,
.media-content video {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 176px);
}

.media-content audio {
  width: min(540px, 100%);
}

.media-fallback {
  color: #fff;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 50;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  max-width: min(390px, calc(100% - 40px));
  padding: 13px 16px;
  border: 1px solid rgb(255 255 255 / 9%);
  border-radius: 14px;
  color: #fff;
  background: rgb(23 23 28 / 94%);
  box-shadow: var(--shadow-float);
  font-size: 12px;
  line-height: 1.5;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.mobile-toolbar {
  display: none;
}

.readonly-composer {
  margin: 0;
}

noscript {
  display: block;
  margin: 20px;
  padding: 14px;
  border: 1px solid #f0c3cb;
  border-radius: 12px;
  color: var(--danger);
  background: #fff0f3;
}

@media (max-width: 1100px) {
  .filter-bar {
    grid-template-columns: minmax(220px, 1.5fr) repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 820px) {
  .app-header {
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-bottom: 9px;
  }

  .brand h1 {
    font-size: 16px;
  }

  .brand .eyebrow {
    display: none;
  }

  .status-pill {
    min-height: 31px;
  }

  .import-layout,
  .viewer {
    grid-template-columns: 1fr;
  }

  .import-layout {
    margin-top: 8px;
  }

  .privacy-card {
    order: 2;
  }

  .conversation-panel {
    position: static;
  }

  .filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    position: static;
  }

  .search-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  html {
    background: #f4f4f6;
  }

  .app-header,
  main {
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  .app-header {
    padding-top: calc(11px + env(safe-area-inset-top));
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .header-actions .button {
    min-height: 36px;
    padding: 7px 9px;
    font-size: 11px;
  }

  main {
    padding-top: 12px;
  }

  .hero-card,
  .privacy-card {
    border-radius: 24px;
  }

  .hero-card {
    padding: 30px 20px 22px;
  }

  .hero-card h2 {
    max-width: 310px;
    font-size: clamp(34px, 10.4vw, 42px);
    letter-spacing: -0.055em;
  }

  .hero-copy {
    margin: 16px 0 22px;
    font-size: 13px;
    line-height: 1.72;
  }

  .drop-zone {
    padding: 22px 12px 18px;
    border-radius: 18px;
  }

  .drop-illustration {
    width: 54px;
    height: 54px;
    margin-bottom: 13px;
    border-radius: 18px;
  }

  .privacy-card {
    padding: 24px 20px;
  }

  body:has(#viewer:not([hidden])) {
    background: #fff;
  }

  body:has(#viewer:not([hidden])) .app-header {
    display: none;
  }

  body:has(#viewer:not([hidden])) main {
    width: 100%;
    padding: 0;
  }

  .viewer {
    display: block;
    min-height: 100dvh;
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
    background: #fff;
  }

  .conversation-panel {
    position: sticky;
    z-index: 20;
    top: 0;
    display: block;
    min-height: calc(64px + env(safe-area-inset-top));
    padding: calc(9px + env(safe-area-inset-top)) 66px 9px 50px;
    border: 0;
    border-bottom: 1px solid rgb(23 23 28 / 7%);
    border-radius: 0;
    background: rgb(255 255 255 / 91%);
    box-shadow: 0 4px 16px rgb(18 18 24 / 5%);
    backdrop-filter: blur(22px) saturate(1.35);
    -webkit-backdrop-filter: blur(22px) saturate(1.35);
  }

  .conversation-panel::before {
    position: absolute;
    top: calc(26px + env(safe-area-inset-top));
    left: 20px;
    width: 10px;
    height: 10px;
    transform: rotate(-45deg);
    border-top: 2px solid #24242a;
    border-left: 2px solid #24242a;
    content: "";
  }

  .archive-heading-row {
    min-width: 0;
    gap: 10px;
  }

  .conversation-avatar {
    width: 42px;
    height: 42px;
    font-size: 13px;
  }

  .archive-heading-row > div {
    min-width: 0;
  }

  .archive-heading .eyebrow {
    display: none;
  }

  .archive-heading h2 {
    overflow: hidden;
    font-size: 16px;
    letter-spacing: -0.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .archive-heading .muted {
    overflow: hidden;
    margin-top: 3px;
    color: #98979f;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .conversation-panel > label:not(#replace-archive),
  #conversation-select,
  .stats-list,
  .signature-card {
    display: none;
  }

  #replace-archive {
    position: absolute;
    top: calc(14px + env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    width: auto;
    min-width: 66px;
    min-height: 34px;
    margin: 0;
    padding: 0 11px 0 27px;
    overflow: hidden;
    border: 1px solid #e7e7eb;
    border-radius: 18px;
    color: #34343b;
    background: #f5f5f7;
    font-size: 12px;
    font-weight: 650;
    line-height: 1;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #replace-archive::before,
  #replace-archive::after {
    position: absolute;
    content: "";
  }

  #replace-archive::before {
    left: 10px;
    width: 12px;
    height: 10px;
    border: 1.6px solid #34343b;
    border-radius: 2px;
  }

  #replace-archive::after {
    top: 8px;
    left: 11px;
    width: 6px;
    height: 4px;
    border: 1.6px solid #34343b;
    border-bottom: 0;
    border-radius: 2px 2px 0 0;
    background: #f5f5f7;
  }

  .message-panel {
    min-height: calc(100dvh - 64px - env(safe-area-inset-top));
    padding: 0 12px calc(24px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
    backdrop-filter: none;
  }

  .filter-bar {
    position: sticky;
    z-index: 10;
    top: calc(60px + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 -12px;
    padding: 9px 12px 10px;
    overflow-x: auto;
    background: rgb(255 255 255 / 93%);
    box-shadow: 0 1px 0 rgb(23 23 28 / 4%);
    scrollbar-width: none;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .filter-bar::-webkit-scrollbar {
    display: none;
  }

  .filter-bar > * {
    flex: 0 0 auto;
  }

  .filter-bar .search-field {
    width: min(70vw, 270px);
  }

  .filter-bar label:not(.search-field) {
    display: block;
    min-width: 104px;
  }

  .filter-bar label:not(.search-field) > span {
    display: none;
  }

  .filter-bar input,
  .filter-bar select {
    min-height: 37px;
    border: 0;
    border-radius: 12px;
    background-color: #fff;
    box-shadow: inset 0 0 0 1px rgb(23 23 28 / 4%);
    font-size: 11px;
  }

  .filter-bar .button {
    width: auto;
    min-height: 37px;
    padding: 8px 12px;
    border-radius: 12px;
    background: #fff;
    font-size: 11px;
    white-space: nowrap;
  }

  .result-heading {
    justify-content: center;
    padding: 13px 4px 4px;
    border: 0;
    color: #a2a1a9;
  }

  #result-count {
    display: none;
  }

  #active-filter-copy {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 9px;
  }

  #active-filter-copy::before,
  #active-filter-copy::after {
    width: 34px;
    height: 1px;
    background: #dedee2;
    content: "";
  }

  .message-list {
    gap: 11px;
    padding: 12px 0 32px;
  }

  .message-item,
  .message-item.is-self {
    width: fit-content;
    max-width: 76%;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 8px;
  }

  .message-item.is-self {
    grid-template-columns: minmax(0, 1fr) 36px;
  }

  .message-item.is-neutral {
    display: flex;
    width: 100%;
    max-width: none;
    padding: 4px 0;
  }

  .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 11px;
  }

  .message-meta {
    margin-bottom: 4px;
  }

  .message-meta strong,
  .message-meta .type-badge {
    display: none;
  }

  .message-item[data-actor-role="interaction_agent"] .message-meta strong {
    display: inline;
    color: #d5652f;
    font-size: 10px;
  }

  .message-item[data-actor-role="interaction_agent"] .bubble {
    border: 1px solid #ffe0c9;
    color: #3a322c;
    background: #fff7f0;
  }

  .message-meta time {
    color: #aaa9b0;
    font-size: 9px;
  }

  .bubble {
    padding: 10px 12px;
    border-radius: 4px 17px 17px;
    background: #f1f1f3;
    box-shadow: none;
  }

  .message-item.is-self .bubble {
    border-radius: 17px 4px 17px 17px;
    color: #fff;
    background: #2788f5;
    box-shadow: none;
  }

  .message-item.is-self .structured-card-title,
  .message-item.is-self .message-text {
    color: #fff;
  }

  .message-item.is-self .structured-card-label,
  .message-item.is-self .structured-card-summary,
  .message-item.is-self .structured-card-object {
    color: rgb(255 255 255 / 78%);
  }

  .message-item.is-self .bubble-card .structured-card-content {
    border-bottom-color: rgb(255 255 255 / 22%);
  }

  .message-text {
    font-size: 14px;
    line-height: 1.58;
  }

  .neutral-card,
  .message-item.is-notice .neutral-card,
  .message-item.is-tombstone .neutral-card {
    max-width: 92%;
  }

  .neutral-card {
    padding: 14px 14px 13px;
    border-radius: 17px;
  }

  .message-item.is-notice .neutral-card,
  .message-item.is-tombstone .neutral-card {
    padding: 6px 10px;
  }

  .bubble-card .structured-card-content {
    min-width: 0;
  }

  .structured-card-title {
    font-size: 13px;
  }

  .interaction-avatar {
    width: 36px;
    height: 36px;
  }

  .mobile-toolbar {
    position: fixed;
    z-index: 35;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    align-items: center;
    gap: 9px;
    min-height: 58px;
    padding: 7px max(12px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border-top: 1px solid rgb(23 23 28 / 7%);
    background: rgb(248 248 249 / 96%);
    box-shadow: 0 -8px 28px rgb(18 18 24 / 6%);
    backdrop-filter: blur(24px) saturate(1.25);
    -webkit-backdrop-filter: blur(24px) saturate(1.25);
  }

  .mobile-toolbar a {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 50%;
    color: #34343b;
    text-decoration: none;
  }

  .mobile-toolbar a:active {
    background: #ebebed;
  }

  .mobile-toolbar svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
  }

  .readonly-composer {
    overflow: hidden;
    padding: 11px 14px;
    border-radius: 19px;
    color: #a0a0a7;
    background: #ededf0;
    font-size: 12px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .toast {
    right: 50%;
    bottom: calc(70px + env(safe-area-inset-bottom));
    left: auto;
    width: max-content;
    max-width: min(280px, calc(100% - 32px));
    transform: translateX(50%);
    padding: 10px 13px;
    border-radius: 12px;
    text-align: center;
  }

  .media-dialog {
    width: 100%;
    max-height: calc(100dvh - env(safe-area-inset-top));
    margin: auto 0 0;
    border-radius: 24px 24px 0 0;
  }

  .dialog-heading {
    padding-top: 13px;
  }

  .media-content {
    max-height: calc(100dvh - 86px - env(safe-area-inset-top));
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}

/* Immersive chat mode. The import page keeps its simple landing surface;
   once an archive opens, only the chat itself remains on screen. */
html:has(body.is-viewing),
body.is-viewing {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #f5f5f5;
}

body.is-viewing .app-header {
  display: none;
}

body.is-viewing main {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

body.is-viewing .viewer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: #f5f5f5;
}

body.is-viewing .chat-header {
  position: relative;
  z-index: 20;
  top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: calc(60px + env(safe-area-inset-top));
  padding: calc(8px + env(safe-area-inset-top)) max(58px, env(safe-area-inset-right)) 8px max(58px, env(safe-area-inset-left));
  border: 0;
  border-bottom: 1px solid rgb(20 20 24 / 7%);
  border-radius: 0;
  background: rgb(249 249 250 / 96%);
  box-shadow: none;
  backdrop-filter: blur(24px) saturate(1.25);
  -webkit-backdrop-filter: blur(24px) saturate(1.25);
}

body.is-viewing .chat-header::before {
  display: none;
}

body.is-viewing .archive-heading {
  min-width: 0;
  max-width: min(70vw, 520px);
}

body.is-viewing .archive-heading-row {
  justify-content: center;
  gap: 9px;
}

body.is-viewing .conversation-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 12px;
  box-shadow: none;
}

body.is-viewing .archive-heading-row > div {
  min-width: 0;
}

body.is-viewing .archive-heading h2 {
  overflow: hidden;
  color: #17171b;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.25;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.is-viewing .archive-heading .muted,
body.is-viewing .archive-heading .eyebrow {
  display: none;
}

.chat-menu-button {
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  bottom: 8px;
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #242429;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chat-menu-button:active {
  background: #ececef;
}

.chat-menu-button svg {
  width: 25px;
  height: 25px;
  fill: currentColor;
}

body.is-viewing .message-panel {
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0 max(14px, env(safe-area-inset-right)) 18px max(14px, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: 0;
  background: #f5f5f5;
  box-shadow: none;
  -webkit-overflow-scrolling: touch;
  backdrop-filter: none;
}

body.is-viewing .result-heading {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

body.is-viewing .message-list,
body.is-viewing .empty-state {
  width: min(820px, 100%);
  margin-right: auto;
  margin-left: auto;
}

body.is-viewing .message-list {
  gap: 12px;
  min-height: 100%;
  padding: 22px 0 24px;
}

body.is-viewing .message-item,
body.is-viewing .message-item.is-self {
  max-width: min(76%, 620px);
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px;
}

body.is-viewing .message-item.is-self {
  grid-template-columns: minmax(0, 1fr) 38px;
}

body.is-viewing .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  box-shadow: none;
}

body.is-viewing .message-meta {
  display: none;
}

body.is-viewing .bubble {
  padding: 10px 13px;
  border: 0;
  border-radius: 5px 17px 17px;
  color: #19191d;
  background: #fff;
  box-shadow: 0 1px 1px rgb(18 18 22 / 4%);
}

body.is-viewing .message-item.is-self .bubble {
  border-radius: 17px 5px 17px 17px;
  color: #fff;
  background: #2f8ff3;
}

body.is-viewing .message-text {
  font-size: 15px;
  line-height: 1.52;
}

body.is-viewing .date-divider {
  padding: 8px 0 4px;
}

body.is-viewing .date-divider::before,
body.is-viewing .date-divider::after {
  display: none;
}

body.is-viewing .date-divider time,
body.is-viewing .message-item.is-notice .neutral-card,
body.is-viewing .message-item.is-tombstone .neutral-card {
  color: #a2a2a8;
  background: transparent;
  box-shadow: none;
}

body.is-viewing .mobile-toolbar {
  position: relative;
  z-index: 30;
  right: auto;
  bottom: auto;
  left: auto;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px 40px;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: calc(58px + env(safe-area-inset-bottom));
  padding: 7px max(10px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  border-top: 1px solid rgb(20 20 24 / 7%);
  background: rgb(249 249 250 / 97%);
  box-shadow: none;
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
}

body.is-viewing .readonly-composer {
  min-width: 0;
  min-height: 40px;
  padding: 10px 13px;
  border-radius: 7px;
  color: #aaaab0;
  background: #fff;
  font-size: 14px;
  line-height: 20px;
}

.composer-icon {
  display: grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 0;
  color: #26262b;
  background: transparent;
  opacity: 1;
}

.composer-icon svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.viewer-menu {
  width: min(430px, 100vw);
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 22px 0 0 22px;
  color: var(--ink);
  background: #f6f6f7;
  box-shadow: -18px 0 50px rgb(17 17 22 / 16%);
}

.viewer-menu::backdrop {
  background: rgb(12 12 16 / 30%);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.viewer-menu-surface {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
}

.viewer-menu-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(58px + env(safe-area-inset-top));
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px 20px;
  border-bottom: 1px solid rgb(20 20 24 / 7%);
  background: rgb(255 255 255 / 94%);
}

.viewer-menu-heading h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.drawer-handle {
  display: none;
}

.drawer-close {
  min-width: 48px;
  min-height: 38px;
  padding: 7px 8px;
  border: 0;
  border-radius: 9px;
  color: #2f8ff3;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.viewer-menu-content {
  padding: 14px 14px calc(22px + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.drawer-section {
  margin-bottom: 12px;
  padding: 17px;
  border: 1px solid rgb(20 20 24 / 5%);
  border-radius: 16px;
  background: #fff;
}

.drawer-section h3 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
}

.viewer-menu .filter-bar {
  position: static;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.viewer-menu .filter-bar > * {
  min-width: 0;
}

.viewer-menu .filter-bar .search-field,
.viewer-menu .filter-bar .button {
  grid-column: 1 / -1;
  width: 100%;
}

.viewer-menu .filter-bar label:not(.search-field) {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.viewer-menu .filter-bar label:not(.search-field) > span {
  display: block;
  color: #85858c;
  font-size: 11px;
  font-weight: 600;
}

.viewer-menu .filter-bar input,
.viewer-menu .filter-bar select,
.viewer-menu .drawer-field select {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 9px;
  background-color: #f4f4f6;
  box-shadow: none;
  font-size: 13px;
}

.viewer-menu #conversation-select {
  display: block;
}

.drawer-filter-status {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0 0;
  color: #919198;
  font-size: 11px;
}

.drawer-field {
  display: grid;
  gap: 6px;
  color: #85858c;
  font-size: 11px;
  font-weight: 600;
}

.viewer-menu .stats-list {
  display: grid;
  margin: 14px 0;
  padding: 14px 0;
}

.viewer-menu .signature-card {
  display: flex;
}

.viewer-menu #replace-archive {
  position: static;
  display: inline-flex;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #fff;
  background: #2f8ff3;
  font-size: 14px;
  font-weight: 700;
  box-shadow: none;
}

.viewer-menu #replace-archive::before,
.viewer-menu #replace-archive::after {
  display: none;
}

.drawer-actions > p {
  margin: 10px 3px 0;
  color: #929299;
  font-size: 11px;
  line-height: 1.55;
  text-align: center;
}

@media (max-width: 560px) {
  body.is-viewing .chat-header {
    min-height: calc(56px + env(safe-area-inset-top));
    padding-top: calc(7px + env(safe-area-inset-top));
    padding-bottom: 7px;
  }

  body.is-viewing .conversation-avatar {
    width: 36px;
    height: 36px;
  }

  body.is-viewing .chat-menu-button {
    bottom: 6px;
  }

  body.is-viewing .message-panel {
    min-height: 0;
    padding-right: max(11px, env(safe-area-inset-right));
    padding-left: max(11px, env(safe-area-inset-left));
  }

  body.is-viewing .message-list {
    padding-top: 18px;
  }

  body.is-viewing .message-item,
  body.is-viewing .message-item.is-self {
    max-width: 80%;
    grid-template-columns: 36px minmax(0, 1fr);
  }

  body.is-viewing .message-item.is-self {
    grid-template-columns: minmax(0, 1fr) 36px;
  }

  body.is-viewing .avatar {
    width: 36px;
    height: 36px;
  }

  .viewer-menu {
    width: 100%;
    height: min(84dvh, 760px);
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -18px 48px rgb(17 17 22 / 18%);
  }

  .viewer-menu-heading {
    position: relative;
    min-height: 58px;
    padding: 17px 15px 9px 20px;
  }

  .drawer-handle {
    position: absolute;
    top: 7px;
    left: 50%;
    display: block;
    width: 36px;
    height: 4px;
    margin: 0;
    transform: translateX(-50%);
    border-radius: 999px;
    background: #d7d7db;
  }

  .viewer-menu-heading h2 {
    font-size: 17px;
  }

  .viewer-menu-content {
    padding: 12px 11px calc(18px + env(safe-area-inset-bottom));
  }

  .drawer-section {
    padding: 15px;
    border-radius: 14px;
  }
}

/* Neutral timeline rows must span the full conversation width. The generic
   human-message cap above also matches these rows; without this override their
   contents are centered inside the leftmost 80% instead of the viewport. */
body.is-viewing .message-item.is-neutral {
  display: flex;
  width: 100%;
  max-width: none;
  margin: 2px 0;
  padding: 0;
  align-items: center;
  align-self: stretch;
  justify-content: center;
  justify-self: stretch;
  gap: 0;
  grid-template-columns: none;
}

body.is-viewing .message-item.is-neutral > .neutral-card {
  margin-right: auto;
  margin-left: auto;
}

body.is-viewing .message-panel {
  padding-right: max(11px, env(safe-area-inset-left), env(safe-area-inset-right));
  padding-left: max(11px, env(safe-area-inset-left), env(safe-area-inset-right));
  scrollbar-gutter: stable both-edges;
}

/* Keep meaningful interaction objects as cards, but size them from the full
   timeline width so their visual centre matches the chat header and composer. */
body.is-viewing .message-item.is-neutral.is-card > .neutral-card {
  width: min(82vw, 304px);
  max-width: 304px;
}

/* Platform notices are timeline copy, not chat bubbles or dashboard pills. */
body.is-viewing .message-item.is-notice > .neutral-card,
body.is-viewing .message-item.is-tombstone > .neutral-card,
body.is-viewing .message-item[data-actor-role="unknown"] > .neutral-card,
body.is-viewing .message-item[data-interaction-kind="relationship"] > .neutral-card,
body.is-viewing .message-item[data-interaction-kind="relationship_theme"] > .neutral-card,
body.is-viewing .message-item[data-interaction-kind="chat_appearance"] > .neutral-card {
  width: auto;
  min-width: 0;
  max-width: min(76vw, 280px);
  padding: 1px 8px;
  border: 0;
  border-radius: 0;
  color: #9b9ba2;
  background: transparent;
  box-shadow: none;
  text-align: center;
}

body.is-viewing .notice-copy,
body.is-viewing .tombstone-copy,
body.is-viewing .message-item[data-actor-role="unknown"] .structured-card-summary,
body.is-viewing .message-item[data-interaction-kind="relationship"] .structured-card-summary,
body.is-viewing .message-item[data-interaction-kind="relationship_theme"] .structured-card-summary,
body.is-viewing .message-item[data-interaction-kind="chat_appearance"] .structured-card-summary {
  color: #9b9ba2;
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
  text-align: center;
}

body.is-viewing .message-item.is-notice .neutral-meta,
body.is-viewing .message-item.is-tombstone .neutral-meta,
body.is-viewing .message-item[data-actor-role="unknown"] .neutral-meta,
body.is-viewing .message-item[data-interaction-kind="relationship"] .neutral-meta,
body.is-viewing .message-item[data-interaction-kind="relationship_theme"] .neutral-meta,
body.is-viewing .message-item[data-interaction-kind="chat_appearance"] .neutral-meta {
  display: none;
}

body.is-viewing .date-divider {
  display: block;
  width: 100%;
  margin: 10px 0 6px;
  padding: 0;
  color: #a3a3aa;
  font-size: 11px;
  font-weight: 400;
  line-height: 16px;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  :root,
  html,
  body {
    background: #fff;
  }

  .app-header,
  .conversation-panel,
  .filter-bar,
  .result-heading,
  .toast,
  .mobile-toolbar {
    display: none !important;
  }

  main,
  .message-panel {
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .viewer {
    display: block;
  }

  .message-item {
    break-inside: avoid;
  }
}
