:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: #f4f5f6;
  background: #090f10;
  --cyan: #15cedd;
  --green: #24dbad;
  --pink: #ff65ad;
  --border: #244044;
  --muted: #b4bfc3;
  --sidebar: 280px;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
button, input, textarea { font: inherit; }
button {
  min-height: 44px;
  padding: 8px 14px;
  color: inherit;
  background: #172023;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.hidden { display: none !important; }
.auth-starting #login-panel { visibility: hidden; }
#history-backdrop { display: none; }
.wordmark { font: 24px Georgia, serif; letter-spacing: .23em; text-transform: uppercase; color: var(--pink); }
.login-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 1040px;
  min-height: 600px;
  margin: clamp(20px, 6vh, 65px) auto;
  border: 1px solid #1d5059;
  border-radius: 28px;
  overflow: hidden;
  background: #0b1213;
  box-shadow: 0 25px 100px #001b1b80;
}
body:not(.signed) {
  background: radial-gradient(ellipse at 8% 12%, #0b382d80, transparent 55%),
    radial-gradient(ellipse at 100% 95%, #07405566, transparent 50%), #090f10;
}
.intro { padding: clamp(34px, 5vw, 64px); background: linear-gradient(145deg, #10322c, #0b1718); border-right: 1px solid var(--border); }
.intro h1 { max-width: 14ch; margin: 22px 0; font-size: clamp(38px, 4.7vw, 66px); line-height: 1.06; letter-spacing: -.045em; }
.intro p, .intro small { color: #b6d2cc; line-height: 1.6; }
.auth-content { align-self: center; padding: clamp(28px, 4vw, 52px); }
.auth-logo { display: block; object-fit: contain; border-radius: 10px; }
.auth-content h2 { font-size: 28px; margin: 20px 0; }
.auth-content label { display: block; margin: 16px 0 7px; font-size: 14px; font-weight: 650; }
.auth-content input {
  width: 100%;
  padding: 14px 16px;
  color: inherit;
  background: #151f21;
  border: 1px solid #405055;
  border-radius: 12px;
}
.auth-content form > button { width: 100%; margin-top: 20px; background: #007983; font-weight: 700; }
#status { min-height: 1.5em; margin-bottom: 0; font-size: 14px; color: #9be4dc; line-height: 1.5; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: var(--sidebar);
  color: #f4f5f6;
  background: #1a1a1d;
  border-right: 1px solid #303136;
}
.account { padding: 13px 12px; border-bottom: 1px solid #303136; }
.account img { border-radius: 50%; }
#account-menu { position: relative; }
#account-menu summary {
  display: flex; align-items: center; gap: 11px; min-height: 56px;
  padding: 7px; cursor: pointer; list-style: none; border-radius: 8px;
}
#account-menu summary::-webkit-details-marker { display: none; }
#account-menu summary:hover, #account-menu[open] summary { background: #243034; }
#account-avatar { flex: none; object-fit: cover; }
#account-menu summary span:nth-child(2) { min-width: 0; flex: 1; }
#user-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-chevron { padding-inline: 5px; color: var(--cyan); }
.account-options { display: grid; gap: 4px; padding-top: 6px; }
.account-options button { text-align: left; background: transparent; border-color: transparent; }
.account-options button:hover { background: #113a3e; }
dialog {
  width: min(460px, calc(100% - 32px));
  max-height: calc(100dvh - 32px); padding: 22px; border: 1px solid var(--border);
  border-radius: 16px; background: #151c1f; color: inherit;
}
dialog::backdrop { background: #000a; }
dialog h2 { margin: 0 0 14px; font-size: 21px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.dialog-actions form { margin: 0; }
#signature-form { display: grid; gap: 10px; }
#signature-form label:not(.consent) { display: grid; gap: 4px; }
#signature-form input:not([type="checkbox"]) {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  color: inherit; background: #101618;
}
#signature-status { margin: 0; }
#projects-list { padding-left: 20px; overflow-wrap: anywhere; }
.account strong, .account small { display: block; }
.account small { margin-top: 3px; font-size: 12px; color: var(--muted); }
.sidebar h2 { margin: 0; padding: 20px 16px; color: var(--cyan); font-size: 13px; text-transform: uppercase; }
.secondary { background: transparent; font-size: 12px; }
.new-chat { background: transparent; color: var(--green); border-radius: 0; border-width: 1px 0; text-align: left; }
#history-list { flex: 1; min-height: 0; padding: 10px 8px; overflow: auto; }
#history-list button {
  display: block;
  width: 100%;
  overflow: hidden;
  margin-bottom: 3px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
}
#history-list button:hover, #history-list button[aria-current="true"] { background: #113a3e; color: #b4f7ef; }
#projects-status { margin: 4px 0; color: var(--muted); }
.chat-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr) auto;
  margin-left: var(--sidebar);
  height: 100dvh;
  background: linear-gradient(#ffffff05 1px, transparent 1px),
    linear-gradient(90deg, #ffffff05 1px, transparent 1px), #101214;
  background-size: 50px 50px;
}
.chat-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 22px; border-bottom: 1px solid #292d31; background: #101214; }
.chat-header button { justify-self: start; padding: 8px 12px; border-color: transparent; background: transparent; color: var(--cyan); }
.company { justify-self: end; color: var(--muted); font-size: 12px; }
.chat-content { position: relative; min-width: 0; min-height: 0; --chat-gutter: clamp(14px, 3vw, 42px); }
.chat-turns { height: 100%; overflow: auto; list-style: none; margin: 0; padding: 20px var(--chat-gutter); overflow-wrap: anywhere; }
.chat-welcome {
  position: absolute; inset: 20px var(--chat-gutter) auto; width: fit-content;
  max-width: min(72%, calc(100% - 2 * var(--chat-gutter))); margin: 0;
  padding: 15px 18px; border: 1px solid #205057; border-radius: 16px; background: #181c20;
}
.chat-content:has(.chat-turns:not(:empty)) .chat-welcome { display: none; }
.chat-turns > li { padding: 17px 20px; margin-bottom: 16px; border: 1px solid #30383e; border-radius: 15px; background: #181c20; }
.chat-turns > li.user { margin-left: 7%; background: #10282b; border-color: #21525a; }
.chat-turns > li > strong { font-size: 13px; color: #7aeee7; }
.chat-turns p { margin: 8px 0 0; line-height: 1.6; }
.chat-turns li.user p { white-space: pre-wrap; }
.chat-turns pre { overflow: auto; padding: 12px; border-radius: 8px; background: #080c10; }
.chat-markdown, .private-draft { min-width: 0; }
.chat-markdown :is(h2, h3, h4), .private-draft :is(h2, h3, h4) {
  margin: 16px 0 6px;
  line-height: 1.3;
}
.chat-markdown > :first-child { margin-top: 8px; }
.chat-markdown pre { white-space: pre; overflow-wrap: normal; tab-size: 4; }
.chat-markdown math[display="block"], .private-draft math[display="block"] {
  margin-block: 10px;
  overflow-x: auto;
  max-width: 100%;
}
.consent { display: flex; align-items: flex-start; gap: 7px; margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.4; }
.consent input { accent-color: var(--cyan); }
#chat-status { margin: 6px 0 0; font-size: 12px; color: #9be4dc; }
#chat-status:empty { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sidebar-collapsed .sidebar { visibility: hidden; }
.sidebar-collapsed .chat-shell { margin-left: 0; }
@media (max-width: 1080px) { .login-shell { margin-inline: 20px; } }
@media (max-width: 850px) {
  .login-shell { min-height: 0; margin-block: 20px; }
  .auth-content { padding-block: 24px; }
}
@media (max-width: 760px) {
  .login-shell { grid-template-columns: 1fr; min-height: 0; margin: 16px; }
  .intro { padding: 26px; border: 0; border-bottom: 1px solid var(--border); }
  .intro h1 { max-width: 18ch; margin: 12px 0; font-size: 32px; }
  .intro p { display: none; }
  .auth-content { padding: 26px; }
  .sidebar { visibility: hidden; inset-block-start: 56px; width: min(var(--sidebar), 86vw); }
  .drawer-open .sidebar { visibility: visible; }
  .drawer-open #history-backdrop:not([hidden]) {
    display: block; position: absolute; inset: 0; z-index: 1;
    padding: 0; border: 0; border-radius: 0; background: #0008;
  }
  .drawer-open #menu-button { position: relative; z-index: 2; }
  .chat-shell { margin-left: 0; grid-template-rows: 56px minmax(0, 1fr) auto; }
  .chat-header, .composer { padding-inline: 12px; }
  .wordmark { font-size: 19px; }
  .company { font-size: 10px; }
  .chat-turns > li { padding: 13px; }
}

.auth-actions { display: flex; gap: 8px; }
.auth-actions button { flex: 1; }
.auth-actions button[aria-pressed="true"] { border-color: var(--cyan); background: #10383d; }
.link-button { margin: 6px 0; padding-left: 0; border-color: transparent; background: transparent; color: #96e1e3; }
.google-button { width: 100%; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

.chat-turns .private-draft { margin: 8px 0 12px; line-height: 1.6; }
.private-draft > :first-child { margin-top: 0; }
.private-draft > :last-child { margin-bottom: 0; }
.private-draft :is(ol, ul) { padding-inline-start: 1.6em; }
.private-draft li + li { margin-top: 6px; }
.chat-turns button[data-draft-group] { margin-inline: 8px; }
.chat-turns button[data-draft-group][aria-pressed="true"] { border-color: var(--cyan); }

/* Chat surfaces */
.google-button { display: flex; align-items: center; justify-content: center; gap: 12px; }
.google-button svg { flex: none; }
.account-dots { color: var(--cyan); font-size: 24px; line-height: 1; }
#account-menu summary > span:not(.account-dots) { min-width: 0; flex: 1; }
#local-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.account-options {
  position: absolute; inset: calc(100% + 6px) 0 auto;
  z-index: 4; padding: 6px;
  background: #192225; border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 16px 32px #0008;
}
#account-menu:not([open]) .account-options { display: none; }
.account-options button { min-height: 37px; }
#menu-button svg { display: block; }
.chat-turns > li {
  width: fit-content; max-width: 72%; min-width: 0;
  border-radius: 18px; background: #171d21;
}
.chat-turns > li.user { margin-inline: auto 0; background: #102b2e; }
#chat-turns { min-width: 0; overflow-x: hidden; }
#chat-turns > li { box-sizing: border-box; width: 85%; max-width: 85%; }
#chat-turns .chat-markdown { max-width: 100%; }
#chat-turns .chat-markdown pre { box-sizing: border-box; width: 100%; max-width: 100%; overflow: auto; }
.draft-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 6px; }
.chat-turns .draft-actions button, .code-actions button, .code-download {
  min-height: 34px; margin: 0; padding: 5px 11px; font-size: .8rem;
}
.code-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 5px 8px 5px 12px; margin-top: 12px;
  border-radius: 10px 10px 0 0; border: 1px solid #25343b; background: #101719;
  font: .75rem ui-monospace, monospace; color: #bdd4d4;
}
.code-actions + pre { margin: 0 0 10px; border-radius: 0 0 10px 10px; line-height: 1.55; }
.code-actions > :first-child { min-width: 0; overflow-wrap: anywhere; }
.code-download { margin-top: 5px; }

.composer {
  padding: 12px clamp(12px, 2vw, 32px) max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid #292d31; background: #111416;
}
.input-row { max-width: 920px; margin-inline: auto; --control-size: 50px; }
.message-controls { display: flex; align-items: flex-end; gap: 8px; }
.message-input {
  display: flex; min-width: 0; flex: 1;
  background: #1a1a1e; border: 1px solid #35383e; border-radius: 25px;
}
.message-input:focus-within, .input-row.dragging .message-input {
  border-color: var(--cyan); box-shadow: 0 0 0 2px #15cedd22;
}
.message-input textarea {
  display: block; width: 100%; min-width: 0; min-height: calc(var(--control-size) - 2px);
  padding: calc((var(--control-size) - 25px) / 2) 14px; max-height: 140px;
  color: inherit; resize: none; border: 0; border-radius: inherit; background: transparent;
  outline: none; line-height: 23px;
}
.message-input textarea::placeholder { color: #a2aab0; opacity: 1; }
.message-controls button.icon-button {
  display: grid; place-items: center; flex: none; min-height: var(--control-size);
  width: var(--control-size); padding: 0; border: 0; border-radius: 50%;
}
.icon-button svg, .history-row svg, #open-plans svg {
  width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.65;
  stroke-linecap: round; stroke-linejoin: round; flex: none;
}
#attachment-button { color: var(--cyan); background: #102e35; }
#attachment-button svg { width: 25px; height: 25px; }
#microphone-button { color: #bac6c9; background: #1b2023; }
#send-chat { background: var(--cyan); color: #092024; }
#send-chat:disabled { opacity: 1; background: #30363b; color: #9aa7ae; }
.message-controls .icon-button:not(:disabled):hover { filter: brightness(1.23); }
.sidebar-footer {
  flex: none; padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid #303136;
}
#open-plans {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 8px 9px; text-align: left; background: #202125; border-color: #35383e;
}
#open-plans:hover { border-color: var(--cyan); }
#open-plans span { display: grid; gap: 3px; border-left: 2px solid var(--cyan); padding-left: 9px; }
#open-plans strong { color: var(--cyan); font-size: .8rem; }
#open-plans small { color: var(--muted); font-size: .72rem; }
#open-plans svg { color: var(--cyan); }
#conversation-form.deleting #confirm-conversation { color: #ffc4cd; border-color: #9a4e5d; background: #43262d; }
#conversation-status { color: #ffc4cd; font-size: .85rem; }
.attachment-chips:not([hidden]) { display: flex; flex-wrap: wrap; gap: 8px; padding: 7px 8px; }
.attachment-chips .attachment-tile, .dm-file-queue .attachment-tile {
  position: relative; display: block; flex: none; width: 53px; height: 53px; padding: 0;
  border: 1px solid #365459; border-radius: 11px; background: #15282d;
}
.attachment-tile-preview { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; border-radius: inherit; }
.attachment-tile-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.attachment-tile-kind {
  display: grid; place-items: end center; width: 27px; height: 34px; padding-bottom: 3px;
  border: 1px solid #6fa9ac; border-radius: 5px 9px 5px 5px; color: #aee7e7;
  font-size: 8px; font-weight: 700; letter-spacing: .05em;
}
.attachment-tile-remove {
  position: absolute; z-index: 1; inset: -5px -5px auto auto; display: grid; place-items: center;
  width: 23px; height: 23px; min-height: 0; padding: 0; border-radius: 50%;
  border-color: #456568; background: #10191d; color: #e0f2f2; line-height: 1;
}
.popover-menu {
  position: fixed; inset: auto; margin: 0; width: max-content; min-width: 174px;
  padding: 5px; border: 1px solid var(--border); border-radius: 12px;
  background: #192225; color: inherit; box-shadow: 0 14px 30px #000a;
}
.attachment-menu { inset: auto auto 76px clamp(12px, 20%, 330px); }
.popover-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px;
  padding: 5px 9px; background: transparent; border: 0; text-align: left; font-size: .8rem;
}
.popover-menu button:hover { background: #25353a; }
.chat-toast {
  position: fixed; right: 16px; bottom: max(84px, calc(70px + env(safe-area-inset-bottom)));
  z-index: 6; max-width: min(420px, calc(100vw - 32px));
  padding: 10px 13px; border: 1px solid #31555e; border-radius: 12px;
  background: #19272b; box-shadow: 0 10px 28px #0008; pointer-events: none;
}

#history-list .history-row { display: flex; align-items: center; gap: 2px; margin-bottom: 3px; }
#history-list .history-row > button { margin: 0; }
#history-list button[data-conversation] { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 0; }
#history-list button[data-conversation] span { overflow: hidden; text-overflow: ellipsis; }
#history-list .history-more { display: grid; flex: none; place-items: center; min-height: 32px; width: 31px; padding: 0; color: #b4c4c9; }
#history-list .history-menu button { display: flex; min-height: 34px; }
#history-list .history-more svg { stroke-width: 2.8; }
#profile-form label { display: block; margin: 9px 0 4px; }
#profile-name, #conversation-name {
  display: block; width: 100%; min-height: 40px; padding: 8px;
  border: 1px solid #41565d; border-radius: 8px; background: #101719; color: inherit;
}
#profile-photo { max-width: 100%; }
#profile-form small, #conversation-warning, #terms-dialog p { color: #bdc9cc; line-height: 1.5; }
#generated-list { padding-left: 0; list-style: none; }
#generated-list li + li { margin-top: 6px; }

.chat-turns > li.chat-progress {
  display: flex; gap: 12px; align-items: center; min-height: 58px;
  padding: 8px 13px; font-size: .85rem; color: #bde5e4;
}
.atom { width: 44px; height: 44px; flex: none; overflow: visible; }
.atom-tracks { fill: none; stroke: #70e6dc; stroke-opacity: .25; stroke-width: .8; }
.electron-inner { fill: #75f2cf; }
.electron-middle { fill: #53ddff; }
.electron-outer { fill: #ff80bc; }
.protons { fill: #ff76b3; }
.reload-response { margin-top: 9px; min-height: 34px; padding: 4px 8px; font-size: .82rem; }
#chat-effects-help { display: block; margin: 4px 0 8px 23px; color: var(--muted); }
#chat-effects-preview:not([hidden]) { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; color: var(--muted); font-size: .85rem; }
@media (max-width: 570px) {
  .chat-turns > li { padding-inline: 10px; }
  .input-row { --control-size: 44px; }
  .message-controls { gap: 6px; }
}
.install-action { margin-top: 8px; margin-bottom: 0; font-size: .86rem; }
#install-guide { color: #c2d0d2; line-height: 1.6; }
@media (max-width: 760px) {
  body.signed { overflow: hidden; }
  .signed #workspace {
    position: fixed; inset: var(--visible-top, 0px) 0 auto;
    height: var(--visible-height, 100dvh);
  }
  .chat-shell { height: 100%; }
  .sidebar { position: absolute; }
  .message-input textarea { font-size: 16px; }
  .chat-content { --chat-gutter: 12px; }
  .chat-turns { overscroll-behavior: contain; }
  .code-actions { flex-wrap: wrap; }
  .chat-toast { bottom: calc(100dvh - var(--visible-height, 100dvh) - var(--visible-top, 0px) + 74px); }
  .attachment-menu { bottom: calc(100dvh - var(--visible-height, 100dvh) - var(--visible-top, 0px) + 73px); left: 12px; }
}
@media (max-width: 380px) {
  .chat-header { padding-inline: 8px; }
  .composer { padding-inline: 8px; }
  .message-controls { gap: 4px; }
  .message-input textarea { padding-inline: 9px; }
  .chat-turns > li { padding-inline: 8px; }
  .draft-actions button, .code-actions button { white-space: normal; }
}
#account-avatar[hidden], #local-avatar[hidden], #install-login[hidden],
#install-account[hidden], #restore-history[hidden], .chat-toast[hidden] { display: none; }

.chat-tabs { display: flex; gap: 6px; margin: 15px 12px 8px; }
.chat-tabs button { flex: 1; min-width: 0; padding-inline: 8px; font-size: .83rem; }
.chat-tabs button[aria-pressed="true"] { border-color: var(--cyan); color: var(--cyan); background: #103338; }
.sidebar-section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sidebar-section[hidden], #dm-content[hidden], #dm-form[hidden] { display: none; }
.sidebar-section .new-chat {
  flex-shrink: 0; margin: 0 12px; border: 1px solid #27747c; border-radius: 11px;
  color: #a4f7f6; background: linear-gradient(115deg, #11434a, #17282b);
}
#dm-list { flex: 1; min-height: 0; overflow: auto; overscroll-behavior-y: contain; padding: 10px 8px; }
.dm-content { display: flex; flex-direction: column; }
.dm-content .chat-turns { flex: 1; height: auto; min-height: 0; }
.dm-content .chat-turns p { white-space: pre-wrap; overflow-wrap: anywhere; }
.dm-heading { display: flex; align-items: center; justify-content: space-between; padding: 6px var(--chat-gutter); }
.dm-heading h2 { font-size: 1rem; overflow-wrap: anywhere; }
#dm-empty, #dm-status { margin: 0; padding: 0 var(--chat-gutter); color: var(--muted); }
#dm-status:not(:empty) { padding-block: 8px; }
#dm-older { align-self: center; }
.dm-identity { min-width: 0; }
#dm-typing { margin: 2px 0 0; color: var(--cyan); font-size: .78rem; overflow-wrap: anywhere; }
.dm-call-actions { display: flex; flex: none; gap: 6px; }
.dm-notification-permission {
  flex: none; align-self: flex-start; align-items: center; gap: 7px;
  margin: 0 12px 4px; padding: 0 8px; border-color: transparent; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: .78rem; font-weight: 550;
}
.dm-notification-permission:not([hidden]) { display: inline-flex; }
.dm-notification-permission:not(:disabled):hover { background: #24262a; border-color: #35383e; color: #f4f5f6; }
.dm-notification-permission svg {
  width: 16px; height: 16px; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.dm-notification-permission[aria-pressed="true"] svg { color: #77d6d8; }
.dm-notification-permission[aria-pressed="true"] .dm-notification-slash { display: none; }
.dm-notice {
  display: flex; align-items: center; gap: 10px; bottom: auto;
  top: max(10px, env(safe-area-inset-top)); pointer-events: auto;
}
#dm-call-dialog { width: min(540px, calc(100vw - 28px)); }
#dm-call-dialog .dialog-actions { flex-wrap: wrap; }
.dm-call-media { position: relative; }
#dm-call-remote, #dm-call-local { border-radius: 10px; background: #101719; object-fit: contain; }
#dm-call-remote { width: 100%; max-height: 45vh; }
#dm-call-local { width: min(28%, 120px); max-height: 20vh; }
#dm-call-remote:not([hidden]) + #dm-call-local { position: absolute; right: 7px; bottom: 7px; }
.dm-content time { color: var(--muted); font-size: .72rem; }
.dm-share { min-height: 36px; margin-left: 8px; font-size: .75rem; }
#dm-input, #dm-invite-link {
  min-width: 0; width: 100%; border: 1px solid var(--border); border-radius: 11px;
  padding: 9px 12px; color: inherit; background: #1a1a1e; font-size: 16px;
}
#dm-input { min-height: 44px; max-height: 9rem; resize: none; }
#dm-send { color: #092024; background: var(--cyan); }
.chat-markdown a { color: #88edeb; }
.chat-markdown .chat-map-link {
  display: inline-block;
  margin-inline-start: .25rem;
  padding: .1rem .45rem;
  border: 1px solid #326067;
  border-radius: 6px;
  text-decoration: none;
  font-size: .88em;
}
.chat-markdown .chat-map-link:hover { background: #24454a; }
.chat-markdown .chat-map-link:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

.assistant-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.assistant-heading > strong { color: #7aeee7; font-size: 13px; }
.source-references { display: inline-flex; align-items: center; flex-wrap: wrap; max-width: 100%; padding-inline-end: 3px; }
.source-dot {
  width: 26px; height: 26px; min-height: 0; padding: 0; display: grid; place-items: center;
  position: relative; isolation: isolate; flex: none;
  border: 1px solid var(--source-border, #375159); border-radius: 50%;
  background: var(--source-bg, #26363b); color: #e3f3f3;
  font-size: .72rem; font-weight: 700; line-height: 1;
  transition: margin-inline-start .18s ease, border-color .18s ease;
}
.source-dot + .source-dot { margin-inline-start: -8px; }
.source-references:hover .source-dot + .source-dot, .source-references:focus-within .source-dot + .source-dot {
  margin-inline-start: 4px;
}
.source-dot[data-tone="0"] { --source-bg: #3b394e; --source-border: #635b85; }
.source-dot[data-tone="1"] { --source-bg: #253b50; --source-border: #4e7495; }
.source-dot[data-tone="2"] { --source-bg: #4c3934; --source-border: #825d51; }
.source-dot[data-tone="3"] { --source-bg: #23474a; --source-border: #477e80; }
.source-dot[data-tone="4"] { --source-bg: #4a3546; --source-border: #80577a; }
.source-dot:focus-visible { z-index: 1; }
.source-dot img[hidden] { display: none; }
.source-dot img { width: 15px; height: 15px; object-fit: contain; }
.source-dot:hover, .source-dot[aria-expanded="true"] { border-color: var(--cyan); }
@media (prefers-reduced-motion: reduce) { .source-dot { transition: none; } }
.source-panel {
  position: fixed; inset: auto; z-index: 8; box-sizing: border-box; margin: 0;
  width: min(290px, calc(100vw - 16px)); max-height: min(290px, calc(100dvh - 16px));
  overflow: auto; padding: 10px; border: 1px solid #39565a; border-radius: 12px;
  color: #e3efef; background: #141d21; box-shadow: 0 10px 28px #0008;
  font-size: .85rem;
}
/* Review snippets stay visible. The authenticated diff shows exact lines
   changed in a complete private source, not a reconstructed chat excerpt. */
.code-review-diff { margin: 12px 0; border: 1px solid #34575d; border-radius: 9px; background: #111a1e; }
.code-review-diff > summary { cursor: pointer; padding: 10px 12px; color: #9debe9; font-weight: 600; }
.code-review-diff > summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.code-review-diff > pre { max-height: 320px; margin: 0; padding: 12px; overflow: auto;
  font: .79rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre;
  border-top: 1px solid #34575d; background: #0e1418; }
.code-diff-add, .code-diff-remove, .code-diff-context { display: block; }
.code-diff-add { color: #a7e9bf; background: #17482e55; }
.code-diff-remove { color: #ffb9b9; background: #58262655; }
.code-diff-context { color: #b8cad0; }

.source-panel > small { display: block; margin-top: 3px; color: #adc2c5; }
.source-panel ol { margin: 7px 0 0; padding-left: 24px; }
.source-panel li { padding: 2px 3px; overflow-wrap: anywhere; }
.source-panel li[data-source-active] { background: #1d383c; border-radius: 5px; }
.source-panel a { display: block; padding: 5px 0; color: #88edeb; }
.source-panel a > small { display: block; color: #adc2c5; }
@media (pointer: coarse) {
  .source-dot { width: 38px; height: 38px; }
  .source-panel a { padding-block: 9px; }
}

.dm-person, .dm-thread-person, .dm-message-meta { display: flex; align-items: center; gap: 8px; }
.dm-person, .dm-thread-person { min-width: 0; }
.dm-heading h2, .dm-thread-person strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-heading { gap: 8px; min-height: 58px; }
.dm-avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; background: #163137; color: #91eeec; font-size: .8rem; font-weight: 700;
}
.dm-avatar[hidden] { display: none; }
.dm-avatar img { width: 100%; height: 100%; object-fit: cover; }
.dm-thread-row { margin-bottom: 5px; }
.dm-thread-line {
  display: flex; align-items: center; border: 1px solid transparent;
  border-radius: 12px; background: #171c20;
}
.dm-thread-line:has(.dm-thread[aria-current="true"]) { border-color: var(--cyan); background: #142428; }
.dm-thread {
  display: flex; flex: 1; min-width: 0; align-items: center; justify-content: space-between;
  gap: 7px; padding: 6px 7px; text-align: start;
  border: 0; border-radius: 11px; background: transparent;
}
.dm-thread:hover:not(:disabled) { background: #25464b66; }
.dm-thread .dm-avatar { width: 30px; height: 30px; }
.dm-thread-mark { display: flex; align-items: center; gap: 4px; color: var(--cyan); font-size: .75rem; }
.dm-icon {
  display: inline-grid; place-items: center; flex: none; width: 42px; height: 42px; min-height: 0;
  padding: 0; border: 1px solid var(--border); border-radius: 50%; background: #162528; color: #a9d9dc;
}
.dm-icon[hidden], .dm-reply-draft[hidden], .dm-file-queue[hidden] { display: none; }
.dm-icon:hover:not(:disabled), .dm-icon:focus-visible, .dm-icon[aria-pressed="true"] { border-color: var(--cyan); color: var(--cyan); }
.dm-icon svg, .dm-thread-mark svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dm-message-meta { flex-wrap: wrap; margin-top: 5px; gap: 2px 7px; }
#dm-messages > li {
  --dm-bubble-width: min(65%, 465px);
  position: relative; max-width: var(--dm-bubble-width); padding: 12px 15px 10px;
}
#dm-messages > li:has(> .dm-bubble-actions) { padding-block-start: 28px; }
#dm-messages > li > p:first-of-type { margin-top: 3px; }
#dm-messages > li.dm-has-reactions { margin-bottom: 28px; }
.dm-icon.dm-quiet-icon {
  width: 34px; height: 34px; border-color: transparent; background: transparent; color: #9dbabd;
}
.dm-icon.dm-quiet-icon:hover:not(:disabled), .dm-icon.dm-quiet-icon:focus-visible,
.dm-icon.dm-quiet-icon[aria-expanded="true"] { color: #b0fbf8; background: #2a55594d; }
.dm-icon.dm-quiet-icon svg { width: 16px; height: 16px; }
.dm-bubble-actions {
  position: absolute; inset-block-start: 1px; inset-inline-end: 4px;
  display: flex; align-items: center; gap: 4px;
}
.dm-bubble-actions .dm-icon { width: 28px; height: 28px; }
#dm-messages > li:has(.dm-bubble-edit) { min-width: min(116px, var(--dm-bubble-width)); }
.dm-bubble-react { opacity: .54; transition: opacity .15s ease, background-color .15s ease; }
#dm-messages > li:hover .dm-bubble-react, .dm-bubble-react:focus-visible,
.dm-bubble-react[aria-expanded="true"] { opacity: 1; }
.dm-reaction-badge {
  display: flex; align-items: center; gap: 3px; position: absolute;
  inset-inline-start: 12px; inset-block-end: 0; transform: translateY(50%); z-index: 1;
  padding: 1px 3px; border: 1px solid #365254; border-radius: 999px; background: #172528;
}
.dm-reaction-badge[hidden], .dm-emoji-picker[hidden] { display: none; }
.dm-reaction-badge button {
  min-height: 22px; padding: 0 3px; border: 0; border-radius: 999px;
  background: transparent; color: #cadcdd; font-size: 12px; line-height: 1;
}
.dm-reaction-badge button[aria-pressed="true"] { background: #2b4245; }
.dm-reaction-badge button:hover { background: #345053; }
.dm-thread-options { margin-inline-end: 3px; }
.dm-message-meta .dm-share { margin-left: 0; }
.dm-reply, .dm-reply-draft {
  border-inline-start: 2px solid var(--cyan); border-radius: 6px; background: #84e6e814; color: #c7edee;
  margin: 0; padding: 5px 9px; font-size: .83rem; overflow-wrap: anywhere;
}
.dm-reply-draft { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.dm-reply, .dm-reply-link {
  display: block; text-align: start; white-space: normal; overflow-wrap: anywhere;
}
.dm-reply { min-height: 0; width: 100%; }
.dm-reply-link {
  border: 0; background: transparent; color: inherit; padding: 0; min-width: 0; min-height: 25px;
}
.dm-reply:hover, .dm-reply-link:hover:not(:disabled) { color: #edffff; }
#dm-messages > li.dm-message-highlight { outline: 2px solid #82dcde; outline-offset: 1px; }
.dm-transcript { margin-top: 5px; }
.dm-transcript > p { color: #c6dce1; font-size: .85rem; }
.dm-transcript > [hidden] { display: none; }
.dm-reply-draft .dm-icon { width: 34px; height: 34px; }
#dm-messages > li:has(.dm-attachment-card) { width: min(330px, var(--dm-bubble-width)); }
.dm-attachment-card { margin-top: 6px; min-width: 0; }
.dm-image-preview {
  display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3;
  max-height: 245px; overflow: hidden; padding: 0; border: 1px solid #355254;
  border-radius: 11px; background: #132326; cursor: zoom-in;
}
.dm-image-preview img { width: 100%; height: 100%; object-fit: cover; }
.dm-image-preview > svg { width: 27px; height: 27px; }
.dm-image-preview > [hidden], #dm-full-photo[hidden] { display: none; }
.dm-image-preview[data-image-error] { color: #e2a6aa; }
#dm-photo-viewer {
  box-sizing: border-box; width: fit-content; max-width: calc(100vw - 26px);
  max-height: calc(100dvh - 26px); padding: 8px;
  border-color: #314b50; background: #0e1719; box-shadow: 0 28px 80px #0009;
}
#dm-photo-viewer::backdrop { background: #090e11df; }
.dm-viewer-toolbar { display: flex; justify-content: flex-end; gap: 6px; padding-bottom: 6px; }
.dm-viewer-toolbar .dm-icon { width: 37px; height: 37px; }
#dm-full-photo {
  display: block; max-width: min(850px, calc(100vw - 46px)); max-height: calc(100dvh - 105px);
  min-width: min(260px, calc(100vw - 46px)); object-fit: contain; border-radius: 10px;
}
#dm-photo-error { margin: 8px; color: var(--muted); }
.dm-audio {
  display: flex; align-items: center; min-width: 0; gap: 9px;
  padding: 5px 9px; border: 1px solid #2c4b50; border-radius: 14px; background: #112529;
}
.dm-audio .dm-audio-play { width: 35px; height: 35px; background: #234147; color: #b5f7f4; }
.dm-audio-play svg { width: 15px; height: 15px; }
.dm-wave { min-width: 0; flex: 1; height: 30px; fill: #64858b; }
.dm-wave rect[data-played] { fill: #5be3dd; }
.dm-file-download {
  display: flex; gap: 8px; align-items: center; max-width: 100%;
  text-align: start; overflow-wrap: anywhere; font-size: .86rem;
}
.dm-image-preview > svg, .dm-file-download svg, .dm-menu-action svg, .dm-attachment-options button svg {
  width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.dm-composer { display: grid; gap: 6px; }
.dm-composer-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dm-input-wrap { position: relative; flex: 1; min-width: 0; }
#dm-input { display: block; padding-inline-end: 45px; }
#dm-emoji-button {
  position: absolute; inset-inline-end: 4px; top: 50%;
  transform: translateY(-50%); width: 36px; height: 36px;
}
.dm-emoji-picker {
  position: fixed; inset: auto; z-index: 20; margin: 0; padding: 6px;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px;
  width: min(256px, calc(100vw - 16px)); max-height: min(244px, calc(100dvh - 16px)); overflow: auto;
  color: #e8f2f1; background: #17262b; border: 1px solid #3b575b;
  border-radius: 14px; box-shadow: 0 12px 32px #000a;
}
.dm-emoji-picker button {
  display: grid; place-items: center; min-height: 34px; padding: 0;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  font-size: 20px; line-height: 1;
}
.dm-emoji-picker button:hover, .dm-emoji-picker button[aria-pressed="true"] {
  background: #29464a; border-color: #386265;
}
.dm-emoji-picker button:focus-visible { outline-offset: -2px; }
.dm-attachment-menu { position: relative; flex: none; }
.dm-attachment-menu > summary { cursor: pointer; list-style: none; }
.dm-attachment-menu > summary::-webkit-details-marker { display: none; }
.dm-menu-panel, .dm-attachment-menu .dm-attachment-options {
  display: grid; gap: 3px; padding: 5px;
  border: 1px solid #324a50; border-radius: 13px; background: #162327; box-shadow: 0 12px 28px #0006;
}
.dm-menu-panel[hidden], .dm-attachment-menu:not([open]) .dm-attachment-options { display: none; }
.dm-thread-panel { margin: 4px 0 6px auto; width: max-content; max-width: 100%; }
.dm-thread-panel button, .dm-attachment-options button {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 7px 10px;
  text-align: start; border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: #d7e6e9; font-size: .86rem;
}
.dm-thread-panel button svg, .dm-attachment-options button svg { color: #77d8da; }
.dm-thread-panel button[data-action="block"] svg { color: #e7a5ab; }
.dm-thread-panel button:hover:not(:disabled), .dm-attachment-options button:hover:not(:disabled),
.dm-thread-panel button:focus-visible, .dm-attachment-options button:focus-visible { background: #25454a; }
.dm-attachment-menu .dm-attachment-options {
  position: absolute; inset-inline-start: 0; bottom: calc(100% + 8px); z-index: 4;
  width: max-content; min-width: 153px;
}
.dm-attachment-menu[open] > summary { color: #091b1e; border-color: var(--cyan); background: var(--cyan); }
.dm-file-queue { display: flex; flex-wrap: wrap; gap: 8px; padding: 5px 2px; margin: 0; list-style: none; }
#dm-camera-preview { display: block; width: min(100%, 480px); max-height: 50dvh; margin: auto; border-radius: 10px; background: #0b1214; }
#dm-record[aria-pressed="true"] { color: #ff9ba9; border-color: #ff9ba9; }
#dm-send:disabled { color: #93aeb1; background: #263338; opacity: .75; }
@media (max-width: 520px) {
  .dm-composer-row { gap: 4px; }
  #dm-messages > li { --dm-bubble-width: 69%; padding-inline: 10px; }
  #dm-messages > li:has(.dm-attachment-card) { width: min(280px, var(--dm-bubble-width)); }
}

@media (pointer: coarse) {
  .dm-icon.dm-quiet-icon { width: 40px; height: 40px; }
  .dm-bubble-actions .dm-icon { width: 36px; height: 32px; }
  .dm-bubble-react { opacity: .78; }
  #dm-messages > li:has(> .dm-bubble-actions) { padding-block-start: 33px; }
  .dm-emoji-picker button { min-height: 38px; }
  .dm-reaction-badge button { min-height: 26px; }
}

/* Arquivos persistidos não ampliam o balão ou quebram o layout. */
.chat-stored-files {display:flex; flex-wrap:wrap; align-items:center; gap:8px; max-width:85%;}
.chat-stored-files strong {flex-basis:100%;}
.stored-file-download {max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
 border:1px solid #27636b; background:#0d2a2e; color:#bcefeb; border-radius:10px; padding:8px 12px;}
.stored-file-download:hover,.stored-file-download:focus-visible {background:#12444a;}
/* Private ZIP review: stays within the selected conversation, no automatic import. */
.chat-stored-files .stored-project-inspect { min-height: 32px; margin: 4px 8px; font-size: .8rem; }
.stored-project-panel { display: grid; gap: 9px; margin: 8px 0; padding: 12px; background: #101a1c; border: 1px solid var(--border); border-radius: 12px; }
.stored-project-panel[hidden] { display: none; }
.stored-project-panel label { display: grid; gap: 6px; font-size: .85rem; }
.stored-project-panel select { width: 100%; max-width: 410px; padding: 9px; background: #142124; border: 1px solid #315258; border-radius: 8px; color: inherit; }
.stored-project-result { overflow-wrap: anywhere; line-height: 1.5; }
.stored-project-result p { max-width: 62ch; margin: 8px 0; }

/* Accessible narrow-screen evidence tables; data stays plain text nodes. */
.chat-table-scroll { width: 100%; max-width: 100%; overflow-x: auto; margin: 12px 0;
  border: 1px solid #334e55; border-radius: 12px; background: #101b21; }
.chat-table-scroll table { width: 100%; border-collapse: collapse; font-size: .91rem; line-height: 1.5; }
.chat-table-scroll th, .chat-table-scroll td { min-width: 125px; padding: 10px 12px;
  border-bottom: 1px solid #294046; text-align: start; vertical-align: top; }
.chat-table-scroll th { color: #a7efea; font-weight: 700; background: #1b3035; }
.chat-table-scroll tr:last-child td { border-bottom: 0; }
.chat-table-scroll tr:nth-child(even) td { background: #17262b; }
.chat-table-scroll:focus-visible { outline: 2px solid #64e4dd; outline-offset: 3px; }

/* Long pasted messages are part of the message, never a downloadable file. */
.inline-message-detail { margin-top: .5rem; max-width: 100%; }
.inline-message-detail > summary { cursor: pointer; font-size: .86rem; opacity: .85; }
.inline-message-body { max-width: 100%; max-height: 18rem; overflow: auto; white-space: pre;
  overflow-wrap: normal; font: .78rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  border: 1px solid var(--line, #394653); border-radius: .55rem; padding: .75rem; }
