:root {
  font:
    16px Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: #30251f;
  background: #faf8f4;
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 11px 14px;
  border-radius: 14px;
}
button:hover {
  background: #eee6de;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid #a18066;
  outline-offset: 2px;
}
.primary {
  background: #6e4a32;
  color: white;
  font-weight: 600;
}
.primary:hover {
  background: #553724;
}
.soft {
  background: #f0eae3;
  font-size: 14px;
}
.muted {
  color: #746960;
}
small {
  display: block;
  font-size: 12px;
}
.brand {
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -1px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 32px;
  line-height: 1.18;
}
h2 {
  font-size: 22px;
}
h3 {
  font-size: 16px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}
input:not([type="checkbox"]):not([type="radio"]),
textarea {
  width: 100%;
  background: #f7f3ee;
  border: 1px solid #ded6ce;
  border-radius: 13px;
  color: #30251f;
  padding: 12px 14px;
  min-width: 0;
}
textarea {
  resize: vertical;
  line-height: 1.5;
}
input[type="checkbox"],
input[type="radio"] {
  accent-color: #6e4a32;
  width: 22px;
  height: 22px;
}
.gate {
  max-width: 440px;
  margin: 9vh auto;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.tip {
  border-top: 1px solid #ded6ce;
  padding-top: 20px;
  font-size: 13px;
  color: #746960;
}
.shell {
  height: 100dvh;
  max-width: 1500px;
  display: grid;
  grid-template-columns: 320px 1fr;
  margin: auto;
  background: #faf8f4;
  overflow: hidden;
}
.sidebar {
  background: #fff;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e4dcd4;
  min-height: 0;
  padding: 16px;
}
.sidebar header,
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 65px;
}
.sidebar-tools {
  display: flex;
  gap: 8px;
  margin: 12px 0 20px;
}
.sidebar-tools button {
  flex: 1;
}
.sidebar #search {
  margin-bottom: 15px;
}
#contacts {
  flex: 1;
  overflow: auto;
}
.contact {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 10px;
}
.contact > div {
  display: flex;
  align-items: center;
  gap: 12px;
}
.contact strong {
  display: block;
  margin-bottom: 5px;
}
.contact small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 190px;
}
.contact.active {
  background: #eee3d7;
}
.avatar {
  width: 44px;
  height: 44px;
  background: #ece1d5;
  color: #6e4a32;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 600;
  flex-shrink: 0;
}
.sidebar footer {
  display: flex;
  flex-direction: column;
  padding-top: 12px;
  border-top: 1px solid #e4dcd4;
  font-size: 13px;
}
.chat {
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: radial-gradient(ellipse at 80% 25%, #f0e8de, #faf8f4 70%);
}
.chat-header {
  justify-content: flex-start;
  background: #ffffffd9;
  padding: 12px 28px;
  border-bottom: 1px solid #e4dcd4;
  flex-shrink: 0;
}
.chat-header small {
  margin-top: 5px;
}
.back {
  display: none;
}
#messages {
  flex: 1;
  overflow: auto;
  padding: 28px clamp(16px, 4vw, 64px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overscroll-behavior: contain;
}
.empty {
  margin: auto;
  text-align: center;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 25px;
}
.empty-icon {
  font-size: 60px;
  color: #8a6a52;
}
.message {
  max-width: min(80%, 580px);
  min-width: 135px;
  border: 1px solid #ded6ce;
  background: #fff;
  padding: 14px 16px 8px;
  border-radius: 18px 18px 18px 5px;
  align-self: flex-start;
  box-shadow: 0 2px 5px #30251f04;
}
.outgoing {
  align-self: flex-end;
  background: #eee3d7;
  border-color: #ded6ce;
  border-radius: 18px 18px 5px 18px;
}
.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}
.message-meta {
  font-size: 11px;
  color: #746960;
  text-align: right;
  margin-top: 7px;
}
.reactions {
  display: flex;
  gap: 3px;
  margin-top: 5px;
}
.reactions button {
  font-size: 14px;
  padding: 5px 9px;
  background: #ffffff80;
}
.reactions button[aria-pressed="true"] {
  background: #e8dcce;
  box-shadow: inset 0 0 0 1px #8a6a52;
}
.media {
  margin-top: 10px;
}
.media audio {
  max-width: 100%;
  width: 280px;
}
.media video,
.media img {
  max-width: 100%;
  max-height: 400px;
  border-radius: 12px;
}
.media .circle {
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  max-width: 270px;
}
.media button {
  display: block;
}
#composer {
  display: flex;
  gap: 5px;
  align-items: flex-end;
  margin: 0 clamp(10px, 3vw, 40px) max(16px, env(safe-area-inset-bottom));
  padding: 8px;
  background: white;
  border: 1px solid #e4dcd4;
  border-radius: 22px;
  box-shadow: 0 5px 20px #30251f10;
}
#text {
  border: 0;
  background: transparent;
  resize: none;
  max-height: 140px;
  min-height: 43px;
}
#composer button {
  flex-shrink: 0;
  min-height: 43px;
  padding: 10px;
}
dialog {
  border: 1px solid #ded6ce;
  border-radius: 24px;
  padding: 24px;
  max-width: min(480px, calc(100vw - 24px));
  width: 480px;
  max-height: 90dvh;
  color: #30251f;
  background: #fff;
  box-shadow: 0 20px 70px #30251f24;
}
dialog::backdrop {
  background: #20170f60;
  backdrop-filter: blur(5px);
}
dialog > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}
dialog > label,
dialog > p,
dialog > button,
dialog > div,
dialog > textarea {
  margin-bottom: 16px;
}
dialog > button.primary {
  width: 100%;
}
dialog video {
  width: 100%;
  max-height: 320px;
  border-radius: 16px;
  object-fit: cover;
}
dialog audio {
  width: 100%;
}
dialog canvas {
  display: block;
  margin: auto;
  max-width: 100%;
  height: auto;
}
.timer {
  text-align: center;
  font-size: 25px;
  font-variant-numeric: tabular-nums;
}
.device {
  padding: 14px 0;
  border-bottom: 1px solid #e4dcd4;
}
.device small {
  margin-top: 8px;
}
.task {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}
.task span {
  flex: 1;
  overflow-wrap: anywhere;
}
.row {
  display: flex;
  gap: 8px;
}
.tasks {
  max-height: 260px;
  overflow: auto;
}
code {
  font-size: 18px;
  user-select: all;
  overflow-wrap: anywhere;
}
#toast {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #383a3f;
  color: white;
  padding: 14px 20px;
  border-radius: 15px;
  max-width: calc(100vw - 24px);
  width: max-content;
  z-index: 1000;
  font-size: 14px;
  box-shadow: 0 8px 25px #30251f30;
}
[hidden] {
  display: none !important;
}
@media (max-width: 700px) {
  .shell {
    display: block;
  }
  .sidebar {
    height: 100dvh;
    padding-top: max(16px, env(safe-area-inset-top));
    border: 0;
  }
  .chat {
    display: none;
  }
  .conversation .sidebar {
    display: none;
  }
  .conversation .chat {
    display: flex;
  }
  .chat-header {
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .back {
    display: block;
    font-size: 30px;
    line-height: 1;
    padding: 0 12px;
  }
  .message {
    max-width: 90%;
  }
  #messages {
    padding: 20px 12px;
  }
  #composer {
    gap: 0;
    margin-left: 8px;
    margin-right: 8px;
  }
  #composer button {
    padding: 8px;
    min-width: 33px;
  }
  #text {
    padding: 10px 5px;
  }
  .gate {
    margin: 5vh auto;
  }
  .media audio {
    width: 240px;
  }
  dialog {
    padding: 20px;
  }
  .sidebar footer {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

button svg {
  vertical-align: middle;
  flex-shrink: 0;
}
.reactions button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.reactions svg {
  width: 16px;
  height: 16px;
}

.check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  overflow-wrap: anywhere;
}
.choices,
.search-results {
  display: flex;
  flex-direction: column;
  max-height: 240px;
  overflow: auto;
  gap: 5px;
}
.search-results button {
  text-align: left;
  overflow-wrap: anywhere;
}
.invite {
  width: 100%;
  background: #f0eae3;
  text-align: left;
}
.poll {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 180px;
}
blockquote,
.reply-bar {
  padding: 10px 12px;
  background: #f0eae3;
  border-left: 3px solid #6e4a32;
  border-radius: 8px;
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}
.reply-bar {
  margin: 4px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}
[hidden] {
  display: none !important;
}
.fingerprint {
  overflow-wrap: anywhere;
  font-size: 12px;
}
select {
  font: inherit;
  padding: 10px;
  border: 1px solid #ded6ce;
  border-radius: 10px;
  max-width: 100%;
}
.call-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.call-body video {
  width: 100%;
  max-height: 42vh;
  background: #30251f;
  border-radius: 14px;
}
.call-body .call-preview {
  max-height: 110px;
}
.danger {
  background: #fce5e3;
  color: #9d2828;
}
:root.dark {
  color-scheme: dark;
  color: #f5f5f6;
  background: #000000;
}
.dark .shell,
.dark .sidebar,
.dark .chat,
.dark dialog,
.dark .chat-header,
.dark #composer {
  background: #17181b;
  color: #f5f5f6;
  border-color: #383a3f;
}
.dark input:not([type="checkbox"]):not([type="radio"]),
.dark textarea,
.dark select,
.dark .incoming {
  background: #222327;
  color: #f5f5f6;
  border-color: #383a3f;
}
.dark .outgoing {
  background: #3a332d;
  color: #f5f5f6;
}
.dark button:hover,
.dark .soft,
.dark blockquote,
.dark .reply-bar,
.dark .invite {
  background: #2c2d32;
  color: #f5f5f6;
}
.dark .muted {
  color: #b5b6ba;
}
.print-sheet {
  display: none;
}
@media print {
  body.printing > * {
    display: none !important;
  }
  body.printing > .print-sheet {
    display: block !important;
    color: #111;
    background: #fff;
    padding: 20px;
  }
  .print-sheet pre {
    font: 12pt/1.5 system-ui;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
  .print-sheet h1 {
    margin-bottom: 18px;
  }
}

.check input {
  flex: 0 0 22px;
  padding: 0;
  margin: 0;
}
.dark .contact.active {
  background: #2c2d32;
  color: #f5f5f6;
}
.dark .avatar {
  background: #383a3f;
  color: #f5f5f6;
}
.dark .reactions button {
  background: #2c2d32;
  color: #f5f5f6;
}
.dark .reactions button[aria-pressed="true"] {
  background: #d5d6da;
  color: #fff;
}
.dark .message {
  border-color: #383a3f;
}
.dark .message-meta {
  color: #b5b6ba;
}
.poll .check {
  line-height: 1.4;
}
.room-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
.room-tile {
  min-width: 0;
  padding: 10px;
  border-radius: 14px;
  background: #f0eae3;
  overflow-wrap: anywhere;
}
.room-tile video {
  width: 100%;
  max-height: 190px;
  border-radius: 10px;
  background: #000000;
}
.dark .room-tile {
  background: #2c2d32;
}
.room-notices {
  padding: 0 12px;
}
.office-dialog {
  width: min(760px, 96vw);
}
.office-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 48vh;
  overflow: auto;
  padding: 3px;
}
.pdf-preview {
  width: 100%;
  height: 60vh;
  border: 0;
  border-radius: 12px;
}
.pdf-canvas {
  max-width: 100%;
  height: auto;
  align-self: center;
  background: white;
  border: 1px solid #ded6ce;
}
.help-dialog {
  width: 640px;
  max-width: min(640px, calc(100vw - 24px));
  overflow-y: auto;
}
.help-dialog > input {
  width: 100%;
  min-width: 0;
  margin-bottom: 12px;
}
.help-topics details {
  border-top: 1px solid #ded6ce;
  padding: 12px 0;
  overflow-wrap: anywhere;
}
.help-topics details[hidden] {
  display: none;
}
.help-topics summary {
  cursor: pointer;
  font-weight: 600;
  padding: 4px 0;
}
.help-topics summary:focus-visible {
  outline: 2px solid #8a6a52;
  outline-offset: 3px;
}
.help-topics ol {
  padding-left: 24px;
  line-height: 1.6;
}
.help-topics li + li {
  margin-top: 10px;
}

/* Beta UI: shared warm light / graphite dark palette. */
:root {
  color-scheme: light;
  --chip-stroke: #ded6ce;
  --chip-muted: #746960;
}
:root.dark {
  --chip-stroke: #383a3f;
  --chip-muted: #b5b6ba;
}
body {
  line-height: 1.45;
}
button {
  min-height: 44px;
  transition: background-color 120ms ease;
}
button:disabled {
  cursor: default;
  opacity: 0.55;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand img {
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}
.gate {
  max-width: 480px;
  margin: clamp(24px, 6vh, 64px) auto;
  gap: 20px;
  border: 1px solid var(--chip-stroke);
  border-radius: 28px;
  background: #fffcf8;
  box-shadow: 0 16px 60px #30251f0a;
}
.gate h1 {
  font-size: clamp(26px, 5vw, 32px);
  letter-spacing: -0.6px;
}
.dark .gate {
  background: #17181b;
}
.shell {
  border-inline: 1px solid var(--chip-stroke);
}
.sidebar header {
  min-height: 56px;
}
.contact {
  border-radius: 16px;
  margin-bottom: 3px;
}
.contact.active {
  box-shadow: inset 3px 0 0 #8a6a52;
}
.contact strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact > div > div {
  min-width: 0;
}
.chat-header > div {
  min-width: 0;
}
#chat-name,
#chat-id {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-header > button:last-child {
  margin-left: auto;
}
.empty {
  max-width: 420px;
}
.empty h2 {
  line-height: 1.3;
}
.empty button {
  margin-top: 22px;
}
.muted {
  color: var(--chip-muted);
}
.office-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.office-actions button {
  flex: 1;
}
.help-dialog > header {
  position: sticky;
  top: -24px;
  z-index: 1;
  background: inherit;
  padding-block: 12px;
}
summary {
  min-height: 44px;
}
* {
  scrollbar-width: thin;
  scrollbar-color: #9b8d7f66 transparent;
}
@media (max-width: 700px) {
  .gate {
    margin: 18px 12px;
    padding: 24px 20px;
    max-width: none;
  }
  #composer {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  #composer button {
    min-width: 40px;
    min-height: 44px;
  }
  .shell {
    border: 0;
  }
  .sidebar {
    padding-top: max(16px, env(safe-area-inset-top));
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Bubbles remain within their chat pane, including long IDs and media. */
.message {
  min-width: 0;
  box-sizing: border-box;
  overflow-wrap: anywhere;
  touch-action: pan-y;
}
.message blockquote {
  margin: 4px 0;
  padding-left: 10px;
  border-left: 3px solid #8a6a52;
  white-space: pre-wrap;
  max-height: 130px;
  overflow: auto;
}
.reactions {
  flex-wrap: wrap;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}
.emoji-grid button {
  min-width: 0;
  font-size: 24px;
  padding: 10px 4px;
}
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.sticker-grid button {
  min-width: 0;
  padding: 5px;
}
.sticker-grid img {
  width: 100%;
  height: 88px;
  object-fit: contain;
}
.media img,
.media video {
  max-width: 100%;
  object-fit: contain;
}
@media (prefers-reduced-motion: no-preference) {
  .message {
    transition: box-shadow 0.15s;
  }
}
.message.swipe-ready {
  box-shadow: -5px 0 #8a6a52;
}

/* CHIP: warm ivory / graphite and silver. */
:root {
  --chip-accent: #6e4a32;
  --chip-tint: #f0eae3;
}
:root.dark {
  --chip-accent: #d5d6da;
  --chip-tint: #2c2d32;
}
.dark .outgoing {
  background: #2c2d32;
}
.dark .reactions button[aria-pressed="true"] {
  color: #0d0d0f;
}
.dark .contact.active {
  box-shadow: inset 3px 0 0 #d5d6da;
}
.dark .empty-icon {
  color: #b5b6ba;
}
.dark .help-topics details {
  border-color: #383a3f;
}
.message blockquote {
  border-color: var(--chip-accent);
}
.message.swipe-ready {
  box-shadow: -5px 0 var(--chip-accent);
}
.message .reactions button {
  min-height: 32px;
  min-width: 34px;
  border-radius: 12px;
  padding: 4px 8px;
}
.reactions {
  align-items: center;
}
.sticker-grid button {
  background: var(--chip-tint);
  border: 1px solid var(--chip-stroke);
  border-radius: 18px;
}
.emoji-grid button {
  background: var(--chip-tint);
  border-radius: 14px;
}
#text {
  flex: 1;
  width: 0;
}
#composer {
  flex-wrap: wrap;
}
@media (max-width: 540px) {
  #composer {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }
  #composer #text {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
  }
  #composer button {
    width: 100%;
    padding-inline: 4px;
  }
  .message {
    max-width: 90%;
    padding: 12px 13px 8px;
  }
  #messages {
    padding: 18px 12px;
    gap: 10px;
  }
}

.dark .primary {
  background: #d5d6da;
  color: #0d0d0f;
}
.dark .primary:hover {
  background: #b5b6ba;
}
.dark input[type="checkbox"],
.dark input[type="radio"] {
  accent-color: #d5d6da;
}
.dark dialog::backdrop {
  background: #0d0d0f99;
}

.sound-options {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sound-option {
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--chip-stroke);
  border-radius: 18px;
}
.sound-option button:first-child {
  flex: 1;
  text-align: left;
}
.sound-option button[aria-pressed="true"] {
  background: var(--chip-tint);
  box-shadow: inset 3px 0 var(--chip-accent);
}

.create-actions {
  display: grid;
  gap: 8px;
}
.create-action {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 16px;
  text-align: left;
  border-radius: 18px;
}
.create-action svg {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
}
.create-action span {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.create-action strong {
  font-size: 16px;
}
.create-action small {
  font-size: 13px;
  font-weight: 400;
}

.filter-option {
  display: flex;
  flex-direction: row;
  text-align: left;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.filter-option input {
  width: 18px;
  height: 18px;
  accent-color: #6e4a32;
}
:root { --chip-filter-accent: #6e4a32; }
.filter-option input { accent-color: var(--chip-filter-accent); }
dialog select { width: 100%; font: inherit; padding: 10px; border-radius: 12px; color: inherit; background: transparent; }


.filter-option input { flex: 0 0 18px; margin: 0; }
