/* The site's tokens (src/styles/globals.scss), copied: this origin can't load
   the site's stylesheet. The embedding page sends its theme over the bridge. */
:root {
  --neutral-50: oklch(95.351% 0.01502 260.812);
  --neutral-100: oklch(93.15% 0.01851 258.434);
  --neutral-200: oklch(88.666% 0.02328 258.425);
  --neutral-300: oklch(82% 0.03 258.553);
  --neutral-400: oklch(69% 0.036 258.68);
  --neutral-500: oklch(55% 0.038 258.807);
  --neutral-600: oklch(39% 0.034 258.934);
  --neutral-700: oklch(23.342% 0.03027 259.058);
  --neutral-800: oklch(13.37% 0.01015 260.667);
  --neutral-900: oklch(8.597% 0.00556 285.155);
  --brand-pink: #e6007e;
  --brand-blue: #4dedff;

  --space-100: 4px;
  --space-200: 8px;
  --space-300: 12px;
  --space-400: 16px;
  --space-600: 24px;
  --radius-200: 8px;
  --radius-300: 12px;
  --radius-bubble: 18px;
  --radius-max: 999px;
  --target-size: 32px;
  --target-size-touch: 44px;
  --duration-fast: 120ms;

  font:
    15px/1.4 system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
}

:root,
:root[data-theme='dark'] {
  color-scheme: dark;
  --surface: var(--neutral-900);
  --surface-panel: var(--neutral-800);
  --surface-hover: var(--neutral-700);
  --border: color-mix(in oklch, var(--neutral-700) 50%, var(--neutral-600));
  --text: var(--neutral-200);
  --text-strong: var(--neutral-50);
  --text-dim: var(--neutral-400);
  --brand: var(--brand-blue);
  --text-on-brand: var(--neutral-900);
  --bubble-theirs: var(--neutral-700);
  --danger: oklch(75% 0.15 25);
}

:root[data-theme='light'] {
  color-scheme: light;
  --surface: var(--neutral-50);
  --surface-panel: var(--neutral-100);
  --surface-hover: var(--neutral-200);
  --border: var(--neutral-200);
  --text: var(--neutral-700);
  --text-strong: var(--neutral-800);
  --text-dim: var(--neutral-600);
  --brand: var(--brand-pink);
  --text-on-brand: var(--neutral-50);
  --bubble-theirs: var(--neutral-200);
  --danger: oklch(52% 0.19 25);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex: none;
}

.dim {
  color: var(--text-dim);
}

.small {
  font-size: 13px;
}

/* ── Collapsed bar ────────────────────────────────────────────── */

.bar {
  display: flex;
  align-items: center;
  gap: var(--space-200);
  width: 100%;
  height: 100%;
  padding: 0 var(--space-400);
  border: 0;
  background: var(--surface-panel);
  color: var(--text-strong);
  text-align: left;
}

.bar strong {
  flex: 1;
}

/* ── Header ───────────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  gap: var(--space-200);
  min-height: 56px;
  padding: var(--space-200) var(--space-300);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-title {
  display: flex;
  align-items: center;
  gap: var(--space-200);
  flex: 1;
  min-width: 0;
}

.header-title strong {
  color: var(--text-strong);
  font-size: 17px;
}

.header-names {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.header-names strong,
.header-names span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.header-names strong {
  font-size: 15px;
}

.header-names span {
  font-size: 13px;
}

.header-actions {
  display: flex;
  gap: var(--space-100);
}

.icon-button {
  display: grid;
  place-items: center;
  width: var(--target-size);
  height: var(--target-size);
  border: 0;
  border-radius: var(--radius-max);
  background: transparent;
  color: var(--text-strong);
}

.icon-button:hover {
  background: var(--surface-hover);
}

@media (pointer: coarse) {
  .icon-button {
    width: var(--target-size-touch);
    height: var(--target-size-touch);
  }
}

.banner,
.notice {
  margin: 0;
  padding: var(--space-200) var(--space-400);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.banner {
  color: var(--text-dim);
  background: var(--surface-panel);
}

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

/* ── Avatars and badges ───────────────────────────────────────── */

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  overflow: hidden;
  border-radius: var(--radius-max);
  background: oklch(0.34 0.07 var(--hue));
  color: oklch(0.9 0.06 var(--hue));
  font-weight: 600;
}

:root[data-theme='light'] .avatar {
  background: oklch(0.88 0.06 var(--hue));
  color: oklch(0.4 0.12 var(--hue));
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-small {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.avatar-medium {
  width: 48px;
  height: 48px;
  font-size: 16px;
}

.badge {
  min-width: 20px;
  padding: 0 6px;
  border-radius: var(--radius-max);
  background: var(--brand);
  color: var(--text-on-brand);
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

/* ── Inbox ────────────────────────────────────────────────────── */

.inbox {
  flex: 1;
  margin: 0;
  padding: var(--space-100) 0;
  overflow-y: auto;
  list-style: none;
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-300);
  width: 100%;
  padding: var(--space-200) var(--space-400);
  border: 0;
  background: transparent;
  text-align: left;
}

.row:hover,
.row[aria-current='true'] {
  background: var(--surface-hover);
}

.row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.row-top,
.row-bottom {
  display: flex;
  align-items: center;
  gap: var(--space-200);
}

.row-name,
.row-preview {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.row-name {
  color: var(--text-strong);
  font-weight: 600;
}

.row-time,
.row-preview {
  color: var(--text-dim);
  font-size: 13px;
}

.row-preview.unread {
  color: var(--text-strong);
  font-weight: 600;
}

.empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-200);
  padding: var(--space-600);
  text-align: center;
}

.empty .icon {
  width: 40px;
  height: 40px;
  color: var(--text-dim);
}

.empty strong {
  color: var(--text-strong);
}

.empty p {
  margin: 0;
}

.primary-button {
  min-height: 40px;
  padding: 0 var(--space-400);
  border: 0;
  border-radius: var(--radius-max);
  background: var(--brand);
  color: var(--text-on-brand);
  font-weight: 600;
}

.primary-button:disabled {
  opacity: 0.5;
}

/* ── New message ──────────────────────────────────────────────── */

.new-message {
  display: flex;
  flex-direction: column;
  gap: var(--space-300);
  padding: var(--space-400);
}

.new-message p {
  margin: 0;
}

.field {
  display: flex;
  align-items: center;
  gap: var(--space-200);
  padding: 0 var(--space-300);
  border: 1px solid var(--border);
  border-radius: var(--radius-200);
  background: var(--surface-panel);
}

.at {
  color: var(--text-dim);
}

.peer-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 0;
  outline: 0;
  background: transparent;
}

/* ── Conversation ─────────────────────────────────────────────── */

.conversation {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: var(--space-300);
  overflow-y: auto;
  list-style: none;
  overscroll-behavior: contain;
}

.encryption-note {
  display: flex;
  align-items: center;
  gap: var(--space-200);
  align-self: center;
  max-width: 300px;
  margin-bottom: var(--space-300);
  padding: var(--space-200) var(--space-300);
  border-radius: var(--radius-200);
  background: var(--surface-panel);
  color: var(--text-dim);
  font-size: 12px;
}

.encryption-note .icon {
  width: 16px;
  height: 16px;
}

.day {
  align-self: center;
  margin: var(--space-300) 0 var(--space-200);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}

.message.own {
  align-self: flex-end;
  align-items: flex-end;
}

.message.theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.message.last {
  margin-bottom: var(--space-200);
}

.bubble {
  padding: var(--space-200) var(--space-300);
  border-radius: var(--radius-bubble);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.own .bubble {
  background: var(--brand);
  color: var(--text-on-brand);
}

.theirs .bubble {
  background: var(--bubble-theirs);
  color: var(--text-strong);
}

.message[data-pending='true'] .bubble {
  opacity: 0.6;
}

.bubble.undecryptable {
  font-style: italic;
  opacity: 0.7;
}

.stamp,
.failed {
  margin-top: 2px;
  padding: 0 var(--space-100);
  color: var(--text-dim);
  font-size: 11px;
}

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

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  text-decoration: underline;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: var(--space-200);
  padding: var(--space-200) var(--space-300) var(--space-300);
  border-top: 1px solid var(--border);
}

.composer-input {
  flex: 1;
  min-height: 40px;
  max-height: 160px;
  padding: 9px var(--space-300);
  border: 1px solid var(--border);
  border-radius: 20px;
  outline: 0;
  background: var(--surface-panel);
  resize: none;
}

.composer-input:focus {
  border-color: var(--brand);
}

.send-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-max);
  background: var(--brand);
  color: var(--text-on-brand);
  transition: opacity var(--duration-fast);
}

.send-button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ── Full page, two panes ─────────────────────────────────────── */

.panes {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  flex: 1;
  min-height: 0;
}

.pane-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
}

.pane-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pane-header {
  display: flex;
  align-items: center;
  gap: var(--space-200);
  min-height: 56px;
  padding: var(--space-200) var(--space-400);
  border-bottom: 1px solid var(--border);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
