:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color: #171a1f;
  background: #f3f1ec;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --teal: #c59b3a;
  --teal-dark: #efd27d;
  --ink: #171a1f;
  --muted: #707780;
  --line: #ddd8cf;
  --surface: #ffffff;
  --viewport-height: 100vh;
  --viewport-top: 0px;
  --input-max-height: 120px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; overflow: hidden; }
@supports (height: 100dvh) {
  :root { --viewport-height: 100dvh; }
}

body {
  position: fixed;
  top: var(--viewport-top);
  left: 0;
  width: 100%;
  height: var(--viewport-height);
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 24px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 12% 9%, rgba(214, 174, 89, .12), transparent 28rem),
    linear-gradient(145deg, #f7f5ef, #eeeae1);
}

button, input, textarea { font: inherit; }

.chat-shell {
  width: min(100%, 540px);
  height: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(25, 59, 78, .08);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(27, 54, 71, .16), 0 3px 10px rgba(27, 54, 71, .06);
}

.chat-header {
  --header-button-size: 40px;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(3, var(--header-button-size));
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  row-gap: 0;
  min-height: 94px;
  padding: 10px 20px;
  color: #fff;
  background: linear-gradient(115deg, #080b0f, #141a21);
  border-bottom: 1px solid rgba(214,174,89,.28);
}

.brand-logo {
  max-width: 100%;
  width: min(190px, 43vw);
  height: 58px;
  padding: 0;
  flex: 0 1 auto;
  object-fit: contain;
  background: transparent;
}

.brand-copy { min-width: 0; flex: 1; }
.brand-copy { grid-column: 1; grid-row: 2; }
.chat-header > .brand-logo { grid-column: 1; grid-row: 1; }
.chat-header > #notification-button { grid-column: 2; grid-row: 1 / span 2; }
.chat-header > #install-button { grid-column: 3; grid-row: 1 / span 2; }
.chat-header > #clear-chat { grid-column: 4; grid-row: 1 / span 2; }
.chat-header:has(> #install-button[hidden]) {
  grid-template-columns: minmax(0, 1fr) repeat(2, var(--header-button-size));
}
.chat-header:has(> #install-button[hidden]) > #clear-chat { grid-column: 3; }
.brand-copy p { margin: 0; display: flex; align-items: center; gap: 7px; color: rgba(255,255,255,.9); font-size: 12px; }
.brand-copy .current-protocol { display: block; margin: 7px 0 0 15px; color: #efd27d; font-size: 12px; overflow-wrap: anywhere; line-height: 1.4; }
.current-protocol strong { user-select: all; font-weight: 600; }
.header-text-button { margin: 5px 0 0 15px; padding: 0; color: rgba(255,255,255,.84); border: 0; background: transparent; cursor: pointer; font-size: 11px; text-decoration: underline; text-underline-offset: 2px; }
.header-text-button:disabled { opacity: .55; cursor: wait; }
#devices-button { display: inline-block; margin-left: 10px; }
.devices-dialog { width: min(94vw, 480px); }
.devices-dialog .protocols-heading h2 { font-size: 22px; margin: 0; line-height: 1.25; }
.devices-dialog .devices-step { margin: 0 0 8px; color: #8f6e26; font-size: 10px; font-weight: 750; letter-spacing: .08em; }
.devices-dialog [data-device-view] > p:first-child { margin-top: 18px; }
.device-choices { display: grid; gap: 12px; margin-top: 20px; }
.device-choice { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 98px; padding: 16px; color: var(--ink); border: 1px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; text-align: left; }
.device-choice:hover:not(:disabled) { border-color: #c59b3a; background: #fcf8ed; }
.device-choice:disabled { opacity: .55; cursor: wait; }
.device-choice > span:nth-child(2) { flex: 1; min-width: 0; }
.device-choice strong { display: block; font-size: 15px; line-height: 1.4; }
.device-choice small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.device-choice-icon { display: grid; place-items: center; flex: 0 0 38px; height: 38px; color: #8f6e26; background: #f5ecd7; border-radius: 11px; font-size: 24px; }
.device-choice-icon svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.qr-camera-frame { position: relative; width: 100%; aspect-ratio: 1; max-height: 40dvh; overflow: hidden; border-radius: 14px; background: #080b0f; }
#pair-camera { display: block; width: 100%; height: 100%; object-fit: cover; }
.qr-camera-guide { position: absolute; inset: 15%; pointer-events: none; border: 2px solid #efd27d; border-radius: 14px; }
#pair-camera-status { font-size: 13px; }
#pair-camera-code { display: block; width: 100%; margin-top: 12px; }
.device-manage { display: block; margin: 22px auto 0; padding: 8px; color: var(--muted); border: 0; background: transparent; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 13px; }
.devices-dialog #devices-back { margin-top: 18px; }
.devices-dialog .pair-code { padding: 12px; border-radius: 12px; background: #f5ecd7; text-align: center; }
.devices-dialog .pair-code-label { font-size: 12px; text-align: center; }
.devices-dialog .pair-validity { font-size: 12px; text-align: center; color: #8f6e26; }
.devices-dialog .device-next { padding: 12px; border-left: 3px solid #c59b3a; background: #f7f5ef; font-size: 13px; }
.devices-dialog [data-device-view] > .primary-button, .devices-dialog #pair-join, .devices-dialog #pair-request-cancel, .devices-dialog #pair-cancel { width: 100%; }
.device-success { margin: 24px auto 12px; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: #f5ecd7; color: #8f6e26; font-size: 32px; }
.devices-dialog h3 { font-size: 16px; margin: 0 0 8px; }
.device-section { padding-block: 18px; border-top: 1px solid var(--line); }
.device-section p { font-size: 13px; }
.devices-status:empty { display: none; }
.devices-status { padding: 10px; border-radius: 10px; background: #f5ecd7; color: #51401c !important; }
.pair-code { display: block; color: var(--ink); font-family: ui-monospace, monospace; font-size: clamp(22px, 7vw, 30px); font-weight: 750; letter-spacing: .1em; overflow-wrap: anywhere; }
#pair-generated, #pair-waiting { margin-top: 16px; }
#pair-qr { display: block; width: min(180px, 100%); height: auto; margin: 12px auto; background: #fff; border-radius: 10px; }
#pair-join-form { display: grid; gap: 12px; }
#pair-input { width: 100%; min-height: 46px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; text-transform: uppercase; }
.pair-consent { display: flex; gap: 9px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.pair-consent input { flex: 0 0 auto; width: 18px; height: 18px; accent-color: #c59b3a; }
.device-card, .pair-approval { margin-top: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; }
.device-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.device-card span { overflow-wrap: anywhere; }
.device-card button { flex: 0 0 auto; }
.pair-approval { background: #f5ecd7; }
.pair-approval p { color: #51401c; }
.pair-approval .dialog-actions { flex-wrap: wrap; margin-top: 12px; }
.status-dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; background: #5ee09a; box-shadow: 0 0 0 3px rgba(94,224,154,.18); }
.status-dot.offline { background: #ff7272; box-shadow: 0 0 0 3px rgba(255,114,114,.18); }

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  color: currentColor;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.icon-button:hover { background: rgba(255,255,255,.14); }
.icon-button:active { transform: scale(.96); }
.icon-button svg, .send-button svg, .welcome-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.notification-button.notifications-enabled { color: #9ff1bc; background: rgba(255,255,255,.12); }
.notification-button.notifications-blocked { color: #ffd18a; background: rgba(255,209,138,.12); }

.conversation {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 22px 18px;
  background: #f3f1ec;
  scroll-behavior: auto;
}

.conversation:has(.welcome-card:not([hidden])) {
  display: grid;
  grid-template-columns: minmax(0, 390px);
  justify-content: center;
  align-content: safe center;
  gap: 12px;
  padding-block: 24px;
}

.conversation:has(.welcome-card:not([hidden])) .welcome-card {
  margin: 0;
}

.conversation:has(.welcome-card:not([hidden])) .messages:empty {
  display: none;
}

.conversation:has(.welcome-card:not([hidden])) .connection-note {
  margin: 0;
}

.welcome-card {
  width: 100%;
  max-width: 390px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  flex-shrink: 0;
  margin: 0 auto 26px;
  padding: 30px 22px 24px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(23, 50, 72, .04);
}
.welcome-icon { width: 46px; height: 46px; margin: 0 auto 12px; display: grid; place-items: center; color: var(--teal); border-radius: 15px; background: #f5ecd7; }
.welcome-icon svg { width: 25px; height: 25px; }
.welcome-card h2 { margin: 0; color: var(--ink); font-size: 17px; }
.welcome-card p { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.identity-form { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.identity-field { display: flex; flex-direction: column; gap: 6px; color: var(--ink); text-align: left; font-size: 13px; font-weight: 650; }
.identity-field input { font-weight: 400; }
.identity-form input { min-width: 0; flex: none; width: 100%; height: 44px; padding: 0 12px; color: var(--ink); border: 1px solid #ddd8cf; border-radius: 11px; outline: 0; font-size: 13px; }
.identity-form .continue-button { width: 100%; min-height: 46px; }
.identity-form input:focus { border-color: #c59b3a; box-shadow: 0 0 0 3px rgba(197,155,58,.18); }
.continue-button { flex: 0 0 auto; min-width: 98px; padding: 0 14px; color: #fff; border: 0; border-radius: 11px; background: var(--teal); cursor: pointer; font-size: 13px; font-weight: 700; }
.continue-button:hover:not(:disabled) { background: var(--teal-dark); }
.continue-button:disabled { opacity: .5; cursor: not-allowed; }
.welcome-card .support-hours-note { padding: 12px; color: #765216; background: #fff4dc; border-radius: 11px; }
.welcome-card small { display: block; margin-top: 12px; color: #707780; font-size: 11px; }

.messages { display: flex; flex-direction: column; gap: 12px; }
.message {
  width: fit-content;
  max-width: min(86%, 410px);
  padding: 11px 13px 8px;
  border: 1px solid #ddd8cf;
  border-radius: 16px 16px 16px 5px;
  color: #30343a;
  background: #eeeae1;
  box-shadow: 0 2px 5px rgba(23, 50, 72, .025);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.45;
}
.message.outgoing { align-self: flex-end; color: #fff; border-color: transparent; border-radius: 16px 16px 5px 16px; background: #d6ae59; }
.message .message-time { display: block; margin-top: 5px; color: #77756e; text-align: right; font-size: 10px; line-height: 1; }
.message-sender { margin-bottom: 4px; color: #c59b3a; font-weight: 700; }
.message p { margin: 0; }
.message p + p { margin-top: .45em; }
.support-menu { display: grid; gap: 8px; margin-top: 14px; white-space: normal; }
.support-menu button { width: 100%; min-height: 46px; padding: 11px 13px; color: #18140c; border: 1px solid #c59b3a; border-radius: 11px; background: #f5ecd7; cursor: pointer; text-align: left; font-weight: 650; line-height: 1.4; overflow-wrap: anywhere; }
.support-menu button:hover:not(:disabled) { background: #efd27d; }
.support-menu button:disabled { opacity: .55; cursor: default; }
.message.outgoing .message-time { color: rgba(255,255,255,.72); }
.message-media { max-width: 100%; max-height: 260px; display: block; margin: 2px 0 6px; border-radius: 10px; object-fit: contain; }
.message-media-frame { position: relative; width: fit-content; max-width: 100%; }
.media-actions { position: absolute; z-index: 2; top: 7px; right: 7px; }
.media-actions summary { width: 32px; height: 32px; display: grid; place-items: center; padding: 0 0 5px; color: #fff; border: 1px solid rgba(255,255,255,.72); border-radius: 50%; background: rgba(24, 36, 48, .76); cursor: pointer; font-size: 24px; font-weight: 700; line-height: 1; list-style: none; }
.media-actions summary::-webkit-details-marker { display: none; }
.media-actions summary:focus-visible { outline: 3px solid #c59b3a; outline-offset: 2px; }
.media-actions-menu { position: absolute; top: 38px; right: 0; min-width: 110px; padding: 4px; border: 1px solid #ddd8cf; border-radius: 10px; background: #fff; box-shadow: 0 8px 24px rgba(17, 42, 58, .2); }
.media-actions-menu a { display: block; padding: 9px 11px; color: #30343a; border-radius: 7px; font-size: 13px; text-decoration: none; white-space: nowrap; }
.media-actions-menu a:hover, .media-actions-menu a:focus-visible { background: #eeeae1; outline: 0; }
.message-media-trigger { display: block; max-width: 100%; padding: 0; border: 0; border-radius: 10px; background: transparent; cursor: zoom-in; text-align: left; }
.message-media-trigger:focus-visible, .message-media-expand:focus-visible, .media-viewer-close:focus-visible { outline: 3px solid #c59b3a; outline-offset: 3px; }
.message-video { width: min(100%, 360px); max-height: 260px; background: #101820; }
.message:has(.message-audio) { width: 376px; }
.message-audio-frame { width: 100%; max-width: 340px; padding-top: 6px; }
.message-audio { display: block; width: 100%; min-width: 0; max-width: 340px; height: 54px; }
.audio-fallback { display: inline-block; margin-top: 7px; color: inherit; font-size: 12px; }
#attachment-audio { order: 3; flex: 1 0 100%; width: 100%; max-width: 340px; }
.attachment-preview:has(#attachment-audio:not([hidden])) { flex-wrap: wrap; }
#audio-dialog .dialog-actions { flex-wrap: wrap; }
#audio-dialog h2 { padding-right: 24px; }
#audio-record-timer { font-weight: 700; color: #a43b28; }
.message-media-expand { display: block; margin: 4px 0 0 auto; padding: 5px 9px; color: #57534a; border: 1px solid #ddd8cf; border-radius: 8px; background: #fff; cursor: pointer; font-size: 12px; }
.message.outgoing .message-media-expand { color: #fff; border-color: rgba(255,255,255,.3); background: rgba(0,0,0,.12); }
.media-viewer { width: min(96vw, 1100px); max-width: none; height: min(94dvh, 900px); max-height: none; padding: 54px 16px 16px; overflow: hidden; border: 0; border-radius: 16px; background: #101820; color: #fff; }
.media-viewer::backdrop { background: rgba(8, 17, 24, .88); }
.media-viewer-close { position: absolute; z-index: 1; top: 10px; right: 12px; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; color: #fff; border: 1px solid rgba(255,255,255,.28); border-radius: 22px; background: rgba(255,255,255,.12); cursor: pointer; font-size: 14px; }
.media-viewer-close span { font-size: 23px; line-height: 1; }
.media-viewer-content { width: 100%; height: 100%; display: grid; place-items: center; }
.media-viewer-content img, .media-viewer-content video { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.media-viewer-content video { width: 100%; height: 100%; }
.message-file { display: block; color: inherit; }
.message-document { display: grid; gap: 9px; min-width: 0; margin: 5px 0; }
.message-document strong { overflow-wrap: anywhere; font-weight: 600; }
.document-download { display: inline-flex; justify-self: start; align-items: center; min-height: 40px; padding: 7px 12px; color: inherit; border: 1px solid currentColor; border-radius: 10px; text-decoration: none; font-size: 13px; font-weight: 600; }
.message-file svg { width: 15px; height: 15px; vertical-align: -3px; margin-right: 4px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.connection-note { margin: 12px auto 0; padding: 8px 12px; color: #805111; border-radius: 10px; background: #fff4df; text-align: center; font-size: 12px; }

.composer { flex: 0 0 auto; min-width: 0; padding: 14px 18px max(12px, env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: #fff; }
.name-field { display: block; margin-bottom: 10px; }
.name-field span { display: block; margin: 0 0 5px 2px; color: #707780; font-size: 11px; font-weight: 650; }
.name-field input {
  width: 100%;
  height: 39px;
  padding: 0 12px;
  color: var(--ink);
  border: 1px solid #ddd8cf;
  border-radius: 11px;
  outline: 0;
  background: #fff;
  font-size: 13px;
}
.name-field input:focus, .compose-row textarea:focus { border-color: #c59b3a; box-shadow: 0 0 0 3px rgba(197,155,58,.18); }
.compose-row { display: flex; align-items: flex-end; gap: 8px; }
.attach-button { flex: 0 0 auto; margin-bottom: 1px; color: #64666a; }
.attach-button:hover { background: #eeeae1; }
.camera-button { display: none; flex: 0 0 auto; margin-bottom: 1px; color: #64666a; }
.camera-button:hover { background: #eeeae1; }
.compose-row textarea {
  flex: 1;
  min-width: 0;
  max-height: var(--input-max-height);
  min-height: 44px;
  resize: none;
  overflow-y: hidden;
  padding: 12px 13px;
  color: var(--ink);
  border: 1px solid #ddd8cf;
  border-radius: 12px;
  outline: 0;
  background: #fff;
  font-size: 13px;
  line-height: 1.4;
}
.send-button {
  height: 44px;
  min-width: 94px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  border: 0;
  border-radius: 12px;
  background: var(--teal);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: background .15s ease, transform .15s ease;
}
.send-button:hover { background: var(--teal-dark); }
.send-button:active { transform: translateY(1px); }
.send-button:disabled { opacity: .55; cursor: wait; }
.send-button svg { width: 17px; height: 17px; }
.attachment-preview { width: fit-content; max-width: calc(100% - 48px); display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 9px 0 0 48px; padding: 4px 7px 4px 10px; color: #57534a; border: 1px solid #ddd8cf; border-radius: 9px; background: #f7f5ef; font-size: 12px; }
.attachment-preview span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-preview button { width: 24px; height: 24px; flex: 0 0 auto; color: #64666a; border: 0; border-radius: 7px; background: transparent; cursor: pointer; font-size: 18px; }
.privacy-note { margin: 9px 0 0 48px; color: #707780; font-size: 10px; }

.app-dialog { width: min(92vw, 420px); max-height: calc(var(--viewport-height) - 24px); overflow-y: auto; padding: 25px; color: var(--ink); border: 1px solid #ddd8cf; border-radius: 20px; background: #fff; box-shadow: 0 24px 80px rgba(17, 42, 58, .24); }
.app-dialog::backdrop { background: rgba(17, 32, 43, .48); backdrop-filter: blur(2px); }
.notification-sound-option { display: flex; align-items: center; gap: 10px; margin-top: 18px; font-weight: 600; line-height: 1.5; }
.notification-sound-option input { width: 22px; height: 22px; flex: 0 0 22px; accent-color: #c49a34; }
#notification-settings .dialog-actions { flex-wrap: wrap; }
#notification-settings h2 { padding-right: 24px; }
.app-dialog h2 { margin: 12px 0 8px; font-size: 20px; }
.app-dialog p { color: var(--muted); font-size: 14px; line-height: 1.55; }
.app-dialog-icon { width: 48px; height: 48px; display: grid; place-items: center; color: var(--teal); border-radius: 15px; background: #f5ecd7; font-size: 25px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.dialog-actions button, .primary-button, .secondary-button { min-height: 42px; padding: 0 15px; border: 0; border-radius: 10px; cursor: pointer; font-weight: 650; }
.primary-button { color: #fff; background: var(--teal); }
.secondary-button { color: #57534a; background: #f3f1ec; }
.dialog-close { width: 34px; height: 34px; color: #64666a; border: 0; border-radius: 9px; background: #eeeae1; cursor: pointer; font-size: 22px; }
.install-dialog-close { position: absolute; top: 12px; right: 12px; }
.protocols-dialog { width: min(94vw, 620px); max-height: min(86dvh, 760px); overflow: auto; }
.protocols-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.protocols-heading h2 { margin-top: 0; }
.protocols-heading p, .protocol-dates { margin: 4px 0 14px; font-size: 12px; }
.protocol-list { display: grid; gap: 9px; }
.protocol-card { display: grid; gap: 5px; width: 100%; padding: 13px; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; background: #f7f5ef; cursor: pointer; text-align: left; }
.protocol-card:hover { border-color: #c59b3a; background: #f5ecd7; }
.protocol-card span { color: var(--muted); font-size: 12px; }
.protocol-state { padding: 18px 10px; color: var(--muted); text-align: center; }
.protocol-detail h3 { margin: 12px 0 0; }
.back-button { padding: 7px 0; color: var(--teal); border: 0; background: transparent; cursor: pointer; font-weight: 650; }
.protocol-messages { display: flex; flex-direction: column; gap: 10px; max-height: 52dvh; padding: 10px 2px; overflow: auto; background: #f3f1ec; }
.protocol-messages .message { max-width: 90%; }
.protocol-messages .message-media { cursor: zoom-in; }

@media (min-width: 561px) {
  body { padding: 24px; }
  .chat-shell { width: min(100%, 1440px); }
  .chat-header { padding: 14px 28px; }
  .conversation { padding: 28px 32px; }
  .conversation:has(.welcome-card:not([hidden])) { grid-template-columns: minmax(0, 560px); }
  .welcome-card { max-width: 560px; padding: 32px; }
  .welcome-card h2 { font-size: 22px; }
  .welcome-card p { font-size: 15px; }
  .identity-form input { height: 52px; font-size: 16px; }
  .identity-form .continue-button { min-height: 52px; font-size: 16px; }
  .welcome-card small { font-size: 12px; }
  .message { max-width: min(78%, 760px); padding: 14px 17px 10px; font-size: 16px; }
  .composer { flex-shrink: 0; padding: 18px 28px 14px; }
  .compose-row { gap: 12px; }
  .compose-row textarea { min-height: 56px; padding: 16px; font-size: 16px; }
  .attach-button { width: 48px; height: 54px; }
  .send-button { height: 56px; min-width: 126px; font-size: 16px; }
  .send-button svg { width: 20px; height: 20px; }
  .privacy-note { margin-left: 60px; font-size: 12px; }
}

@media (max-width: 560px) {
  .camera-button { display: inline-grid; }
  html { height: 100%; overflow: hidden; }
  body { display: block; padding: 0; background: #f3f1ec; }
  .chat-shell { width: 100%; height: 100%; min-height: 0; border: 0; border-radius: 0; box-shadow: none; }
  .chat-header { --header-button-size: 36px; min-height: 82px; padding: max(8px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) 8px max(10px, env(safe-area-inset-left, 0px)); column-gap: 4px; }
  .chat-header > #notification-button, .chat-header > #install-button, .chat-header > #clear-chat { width: 36px; height: 36px; }
  .brand-logo { width: min(170px, 52vw); height: 45px; }
  .header-text-button { margin-left: 15px; font-size: 10px; }
  .identity-form { flex-direction: column; }
  .welcome-card { min-height: 0; }
  .identity-form input { flex: none; width: 100%; }
  .continue-button { width: 100%; min-height: 44px; }
  .conversation { padding: 18px 14px 15px; overscroll-behavior-y: contain; }
  .composer { padding: 11px max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); }
  .identity-form input, .compose-row textarea { font-size: 16px; }
  .compose-row textarea { min-height: 46px; padding: 11px 10px; line-height: 22px; }
  .send-button { min-width: 76px; }
  .send-button svg { display: none; }
  .message { max-width: 91%; }
  .media-viewer { width: 100vw; height: var(--viewport-height); padding: 58px 8px max(10px, env(safe-area-inset-bottom)); border-radius: 0; }
}

/* Reduz os espaços em notebooks e janelas baixas, sem cortar o formulário. */
@media (max-height: 700px) {
  body { padding-block: 12px; }
  .chat-header { min-height: 76px; padding-block: 8px; }
  .brand-logo { height: 44px; }
  .conversation:has(.welcome-card:not([hidden])) { padding-block: 16px; }
  .welcome-card { padding: 20px; }
  .welcome-icon { width: 38px; height: 38px; margin-bottom: 8px; }
  .identity-form { margin-top: 18px; }
}

@media (max-width: 560px) and (max-height: 700px) {
  body { padding: 0; }
}

@media (max-width: 360px) {
  .compose-row { gap: 5px; }
  .compose-row .icon-button { width: 32px; }
  .send-button { min-width: 64px; padding-inline: 9px; }
  .composer { padding-inline: 8px; }
  .privacy-note { margin-left: 0; }
}

/* O teclado pode reduzir a área visível sem alterar o viewport usado pelo CSS. */
body.compact-viewport .chat-header { min-height: 0; padding-top: 6px; padding-bottom: 6px; }
body.compact-viewport .brand-logo { height: 30px; }
body.compact-viewport .composer { padding-top: 6px; }
body.compact-viewport .privacy-note { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Paleta compartilhada com o site institucional: carvão, dourado e marfim. */
.continue-button, .send-button, .primary-button, .message.outgoing { color: #18140c; }
.message.outgoing .message-time { color: #51401c; }
.message.outgoing .message-media-expand { color: #18140c; border-color: rgba(24,20,12,.25); background: rgba(255,255,255,.3); }
.chat-header .icon-button { color: #efd27d; }
.chat-header .notifications-enabled { color: #9ff1bc; }
button:focus-visible, a:focus-visible { outline: 3px solid #c59b3a; outline-offset: 3px; }

/* Central de ajuda: manuais abrem sem substituir a conversa. */
.help-dialog{position:relative;width:min(92vw,480px)}
.help-dialog h2{padding-right:24px}
.help-options{display:grid;gap:12px;margin-top:20px}
.help-options a{display:grid;gap:6px;padding:18px;border:1px solid #ddd8cf;border-radius:14px;background:#f8f5ed;color:var(--ink);text-decoration:none;overflow-wrap:anywhere}
.help-options a:hover{border-color:#b58a20;background:#f5ecd7}
.help-options a:focus-visible{outline:3px solid #b58a20;outline-offset:3px}
.help-options strong{font-size:16px;line-height:1.4}
.help-options span{font-size:14px;line-height:1.5;color:var(--muted)}
.help-options small{margin-top:4px;font-size:12px;font-weight:600;color:#80601b}

#invitation-banner a{color:inherit;text-underline-offset:2px}#invite-dialog .dialog-actions{flex-wrap:wrap}#invite-dialog h2{padding-right:0}

#invite-general-link{display:flex;align-items:center;justify-content:center;text-decoration:none;margin-top:16px}#invite-entry-state h2{font-size:clamp(21px,4vw,28px)}
