:root {
  --ink: #0f1715;
  --muted: #8b918e;
  --text-secondary: #5a635f;
  --paper: #f4f6f5;
  --white: #ffffff;
  --primary: #0f5c54;
  --primary-hover: #0c4a44;
  --primary-soft: #e6f2ef;
  --primary-ring: rgba(15, 92, 84, 0.16);
  --line: #e6ebe9;
  --line-strong: #d5ddd9;
  --shadow: 0 24px 64px rgba(8, 28, 24, 0.18), 0 4px 16px rgba(8, 28, 24, 0.06);
  --shadow-soft: 0 2px 10px rgba(8, 28, 24, 0.05);
  --radius: 10px;
  --panel-radius: 24px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
  font-family: "Work Sans", "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 88% -8%, rgba(15, 92, 84, 0.12), transparent 58%),
    radial-gradient(640px 320px at 4% 100%, rgba(15, 92, 84, 0.05), transparent 55%),
    var(--paper);
}

body.chat-page {
  background: var(--paper);
  overflow: hidden;
}

body.chat-page .chat {
  inset: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  padding: 0;
  gap: 0;
  align-items: stretch;
  background: var(--paper);
}

body.chat-page .launcher {
  display: none !important;
}

body.chat-page .panel {
  width: 100%;
  height: 100%;
  max-width: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  animation: none;
}

body.chat-page .panel-head {
  padding-inline: clamp(16px, 4vw, 40px);
}

body.chat-page .log,
body.chat-page .choices,
body.chat-page .composer-shell,
body.chat-page .composer-hint,
body.chat-page .gate-preview {
  width: min(760px, 100%);
  margin-inline: auto;
}

body.chat-page .msg-row {
  width: fit-content;
  max-width: 100%;
}

body.chat-page #fullscreen {
  display: none !important;
}

body.chat-page .gate-preview {
  padding: 28px 16px;
}

body.chat-page .gate-card {
  width: min(520px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
}

.site {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 28px;
}

.mark {
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 0.5em;
  line-height: 1.2;
}

.site-note {
  color: var(--muted);
  font-size: 13px;
}

.stage {
  max-width: 640px;
  padding: 8vh 28px 140px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

h1 {
  margin: 0;
  font-family: "Instrument Serif", "Times New Roman", Georgia, serif;
  font-weight: 400;
  font-size: clamp(38px, 6.2vw, 60px);
  line-height: 1.04;
  letter-spacing: -0.02em;
}

.lead {
  max-width: 48ch;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1.55;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.chat {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

.launcher {
  position: relative;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 10px 24px rgba(15, 92, 84, 0.35), 0 2px 6px rgba(8, 28, 24, 0.12);
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: visible;
  z-index: 2;
  transition: transform 180ms var(--ease), background 160ms ease, box-shadow 180ms ease;
}

.launcher-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 3;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-family: "Work Sans", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
  pointer-events: none;
  animation: badge-pop 220ms var(--ease);
}

@keyframes badge-pop {
  0% { transform: scale(0.4); }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.launcher-badge[hidden] {
  display: none !important;
}

.launcher:hover {
  transform: translateY(-2px);
  background: var(--primary-hover);
  box-shadow: 0 14px 28px rgba(15, 92, 84, 0.4);
}

.chat[data-open="true"] .launcher:hover {
  background: var(--primary-hover);
}

.launcher:active { transform: scale(0.97); }

.launcher svg,
.icon-btn svg,
#send svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.launcher .launcher-mark {
  width: 30px;
  height: 30px;
  fill: #fff;
  stroke: none;
}

.launcher .launcher-mark .smile {
  fill: none;
  stroke: var(--primary);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.launcher:hover .launcher-mark .smile {
  stroke: var(--primary-hover);
}

.launcher .close-icon { display: none; }
.chat[data-open="true"] .launcher .open-icon { display: none; }
.chat[data-open="true"] .launcher .close-icon { display: block; }
.chat[data-open="true"] .launcher {
  background: var(--primary);
  overflow: hidden;
}

.panel {
  width: min(400px, calc(100vw - 28px));
  height: min(640px, calc(100vh - 104px));
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid rgba(15, 42, 38, 0.06);
  border-radius: var(--panel-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transform-origin: bottom right;
  animation: panel-in 280ms var(--ease);
}

.panel[hidden] { display: none; }

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 14px 14px 16px;
  background: linear-gradient(160deg, #147066 0%, var(--primary) 55%, #0d4f48 100%);
  color: var(--white);
}

.who {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.who-copy {
  min-width: 0;
}

.who strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.status {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-wrap {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
}

.avatar-stack[data-count="2"] {
  width: 68px;
  height: 40px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 18%;
  display: block;
  background: #d7ebe7;
  box-shadow: none;
  border: 0;
}

.avatar-stack .avatar {
  position: absolute;
  top: 0;
  left: 0;
  box-shadow: 0 0 0 2px #fff;
}

.avatar-stack[data-count="2"] .avatar {
  width: 40px;
  height: 40px;
}

.avatar-stack[data-count="2"] .avatar:nth-child(1) {
  left: 0;
  z-index: 1;
}

.avatar-stack[data-count="2"] .avatar:nth-child(2) {
  left: 28px;
  z-index: 2;
}

.presence {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 2px #0f5c54;
  z-index: 3;
}

.avatar-stack[data-count="2"] .presence {
  right: 1px;
}

.head-actions {
  display: flex;
  gap: 2px;
  align-items: center;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 140ms ease, transform 140ms ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn svg { width: 17px; height: 17px; }

.icon-btn .fs-exit { display: none; }
.chat[data-fullscreen="true"] .icon-btn .fs-enter { display: none; }
.chat[data-fullscreen="true"] .icon-btn .fs-exit { display: block; }

.icon-btn .sound-off { display: none; }
.icon-btn[data-muted="true"] .sound-on { display: none; }
.icon-btn[data-muted="true"] .sound-off { display: block; }

.gate {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--paper);
}

.gate[hidden] { display: none; }

.gate-preview {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  filter: blur(5px);
  opacity: 0.72;
  transform: scale(1.015);
  pointer-events: none;
  user-select: none;
}

.gate-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(244, 246, 245, 0.2) 0%,
    rgba(244, 246, 245, 0.55) 70%,
    rgba(244, 246, 245, 0.82) 100%
  );
  pointer-events: none;
}

.gate-preview .bubble {
  max-width: min(78%, 28rem);
}

.gate-preview .bubble.user {
  align-self: flex-end;
}

.gate-card {
  position: relative;
  z-index: 2;
  width: 100%;
  flex: none;
  text-align: left;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--white);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 28px rgba(8, 28, 24, 0.06);
}

.gate-title {
  margin: 0;
  font-family: "Work Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  font-weight: 700;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.gate-copy {
  margin: 6px 0 14px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gate-form input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.gate-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.gate-form input.is-invalid {
  border-color: #b42318;
  box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.12);
}

.gate-error {
  margin: 0;
  color: #b42318;
  font-size: 13px;
}

.gate-error[hidden] { display: none; }

.gate-submit {
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: var(--white);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 13px 16px;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}

.gate-submit:hover { background: var(--primary-hover); }
.gate-submit:active { transform: scale(0.99); }

.panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

.panel-body[hidden],
.composer[hidden] {
  display: none;
}

.composer-hint-label {
  flex: none;
}

.composer-hint #email-chip {
  color: var(--primary);
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat[data-gated="false"] .gate { display: none; }

.log {
  flex: 1;
  overflow: auto;
  padding: 14px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.day-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 6px 0 2px;
  align-self: stretch;
  max-width: none;
}

.day-sep-line {
  flex: 1;
  height: 1px;
  background: var(--line);
}

.day-sep-label {
  flex: none;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  animation: bubble-in 220ms var(--ease);
}

.msg-row.agent {
  align-self: flex-start;
  justify-content: flex-start;
}

.msg-row.user {
  align-self: flex-end;
  justify-content: flex-end;
}

.msg-avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  user-select: none;
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.msg-avatar.agent {
  background: #d7ebe7;
}

.msg-avatar.user {
  background: var(--primary);
  color: var(--white);
}

.bubble {
  width: fit-content;
  max-width: 100%;
  padding: 11px 14px;
  border-radius: 18px;
  line-height: 1.48;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
}

.msg-stack {
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  min-width: 0;
  /* Leave room for avatar; long messages still fill almost the full log width */
  max-width: calc(100% - 36px);
  width: auto;
}

.msg-row.agent .msg-stack {
  align-items: flex-start;
}

.msg-row.user .msg-stack {
  align-items: flex-end;
}

.msg-row .bubble {
  width: fit-content;
  max-width: 100%;
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.bubble.agent {
  background: var(--white);
  border: 0;
  border-bottom-left-radius: 6px;
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.bubble-meta {
  margin-top: 4px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.bubble.user {
  background: var(--primary);
  color: var(--white);
  border-bottom-right-radius: 6px;
  box-shadow: none;
}

.bubble.agent a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bubble.user a {
  color: var(--white);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bubble.system {
  align-self: center;
  max-width: 100%;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 0;
  box-shadow: none;
  animation: none;
}

.typing-row {
  animation: none;
}

.typing {
  display: flex;
  gap: 5px;
  padding: 13px 15px;
  border-radius: 18px;
  background: var(--white);
  border: 0;
  box-shadow: var(--shadow-soft);
}

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1s infinite;
}

.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}

.choices:empty { display: none; }

.choices button {
  border: 1px solid var(--primary);
  background: var(--white);
  color: var(--primary);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.choices button:hover {
  background: var(--primary);
  color: var(--white);
  transform: translateY(-1px);
}

.composer {
  padding: 10px 12px 12px;
  background: transparent;
  border-top: 0;
}

.attachments {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  margin: 0 0 8px;
  overflow-x: auto;
  padding: 6px 2px 2px;
}

.attachments[hidden] { display: none; }

.attach-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  max-width: 190px;
  min-height: 52px;
  padding: 4px;
  border-radius: 12px;
  background: #f3f5f7;
}

.attach-tile.is-error {
  background: #fff5f4;
  outline: 1px solid #f0b4ae;
}

.attach-tile-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  background: #fff;
  flex: none;
}

.attach-tile-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  background: #fee2e2;
  color: #e11d48;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.attach-tile-icon.kind-word {
  background: #dbeafe;
  color: #2563eb;
}

.attach-tile-name {
  min-width: 0;
  padding-right: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attach-tile.is-image {
  padding: 0;
  background: transparent;
  max-width: none;
}

.attach-tile-x {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #111827;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.emoji-pop {
  position: absolute;
  left: 8px;
  bottom: 52px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(8, 32px);
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.emoji-pop[hidden] { display: none; }

.emoji-pop button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
}

.emoji-pop button:hover {
  background: var(--paper);
}

.file-chip {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: min(100%, 100%);
  padding: 8px 8px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
}

.file-chip.is-pending {
  background: var(--white);
}

.file-chip.is-error {
  border-color: #f0b4ae;
  background: #fff5f4;
}

.file-chip-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  flex: none;
}

.file-chip-icon.kind-image {
  background: #eef3f8;
  color: #3b6ea5;
}

.file-chip-icon.kind-word {
  background: #eef2fb;
  color: #3b5bdb;
}

.file-chip-icon.kind-pdf,
.file-chip-icon.kind-file {
  background: var(--primary-soft);
  color: var(--primary);
}

.file-chip-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-chip-body {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.file-chip-body strong {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip-body em {
  font-style: normal;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.01em;
}

.file-chip-actions {
  display: flex;
  gap: 2px;
  align-items: center;
}

.file-chip-btn {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  text-decoration: none;
  padding: 0;
  transition: background 140ms ease, color 140ms ease;
}

.file-chip-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-chip-btn:hover:not(:disabled):not([aria-disabled="true"]) {
  background: var(--paper);
  color: var(--primary);
}

.file-chip-btn:disabled,
.file-chip-btn[aria-disabled="true"] {
  opacity: 0.35;
  cursor: not-allowed;
}

.file-chip-btn.danger {
  color: #9b4a43;
}

.file-chip-btn.danger:hover {
  background: #fff5f4;
  color: #b42318;
}

.bubble.file-wrap {
  align-self: flex-end;
  width: fit-content;
  max-width: min(100%, 320px);
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  animation: bubble-in 220ms var(--ease);
}

.bubble.file-wrap .file-chip {
  background: var(--white);
  box-shadow: var(--shadow-soft);
}

.lightbox[hidden] { display: none; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 28, 24, 0.55);
  backdrop-filter: blur(4px);
}

.lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  height: min(860px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.lightbox-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

.lightbox-meta {
  min-width: 0;
}

.lightbox-meta strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-meta span {
  color: var(--muted);
  font-size: 12px;
}

.lightbox-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.lightbox-btn {
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: var(--white);
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.lightbox-btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.lightbox-body {
  flex: 1;
  min-height: 0;
  background: #f4f5f4;
  display: flex;
}

.lightbox-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  margin: auto;
}

.lightbox-body iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}

.lightbox-empty {
  color: #14211e;
  text-align: center;
  padding: 24px;
  max-width: 36ch;
  line-height: 1.5;
  margin: auto;
}

.composer-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px 8px;
  border: 1.5px solid var(--primary);
  border-radius: 18px;
  background: var(--white);
  box-shadow: 0 0 0 3px var(--primary-ring);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.composer-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 40px;
}

.attach-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  flex: none;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.attach-btn:hover:not(:disabled) {
  background: var(--primary-soft);
  color: var(--primary);
}

.attach-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.attach-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.composer-shell:focus-within {
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

textarea {
  width: 100%;
  resize: none;
  border: 0;
  outline: none;
  font: inherit;
  font-size: 15px;
  line-height: 1.45;
  max-height: 140px;
  color: var(--ink);
  background: transparent;
  padding: 4px 2px 6px;
}

textarea::placeholder {
  color: #9aa3a0;
}

.composer-hint {
  display: flex;
  align-items: baseline;
  gap: 0.3em;
  margin: 8px 6px 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}

#send {
  width: 36px;
  height: 36px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  display: grid;
  place-items: center;
  flex: none;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}

#send:hover {
  background: var(--primary-hover);
}

#send:active { transform: scale(0.96); }
#send svg { width: 17px; height: 17px; }
#send:disabled,
textarea:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Fullscreen — only while the panel is open (never cover the page when closed) */
.chat[data-fullscreen="true"][data-open="true"] {
  inset: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  gap: 0;
  align-items: stretch;
  background: var(--paper);
}

.chat[data-fullscreen="true"][data-open="true"] .launcher {
  display: none;
}

.chat[data-fullscreen="true"][data-open="true"] .panel {
  width: 100%;
  height: 100%;
  max-width: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  animation: none;
}

.chat[data-fullscreen="true"][data-open="true"] .panel-body,
.chat[data-fullscreen="true"][data-open="true"] .gate {
  background: var(--paper);
}

.chat[data-fullscreen="true"][data-open="true"] .gate-card {
  width: min(480px, 100%);
}

.chat[data-fullscreen="true"][data-open="true"] .log {
  width: 100%;
  margin: 0;
  padding: 16px 12px 12px;
}

.chat[data-fullscreen="true"][data-open="true"] .choices {
  width: 100%;
  margin: 0;
  padding-left: 28px;
  padding-right: 28px;
}

.chat[data-fullscreen="true"][data-open="true"] .composer {
  padding: 12px 28px 20px;
  background: linear-gradient(180deg, transparent, rgba(244, 246, 245, 0.85) 28%, var(--paper));
}

.chat[data-fullscreen="true"][data-open="true"] .composer-shell {
  width: 100%;
  margin: 0;
}

.chat[data-fullscreen="true"][data-open="true"] .composer-hint {
  width: 100%;
  margin: 8px 0 0;
}

.chat[data-fullscreen="true"][data-open="true"] .msg-row {
  width: fit-content;
  max-width: 100%;
}

.chat[data-fullscreen="true"][data-open="true"] .msg-row .bubble {
  width: fit-content;
  max-width: 100%;
}

.chat[data-fullscreen="true"][data-open="true"] .bubble.file-wrap {
  max-width: min(100%, 420px);
}

.chat[data-fullscreen="true"][data-open="true"] .panel-head {
  padding: 16px 28px;
}

.chat[data-fullscreen="true"][data-open="true"] .who {
  width: auto;
  max-width: none;
}

body:has(.chat[data-fullscreen="true"][data-open="true"]) {
  overflow: hidden;
}

/* Mobile + tablet (data-compact, set from the page viewport): open chat is always edge-to-edge fullscreen */
.chat[data-compact="true"]:not([data-page="true"]) #fullscreen {
  display: none !important;
}

.chat[data-compact="true"][data-open="true"] {
  inset: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  height: 100dvh !important;
  max-width: none !important;
  padding: 0 !important;
  gap: 0 !important;
  align-items: stretch !important;
  background: var(--paper) !important;
}

.chat[data-compact="true"][data-open="true"] .launcher {
  display: none !important;
}

.chat[data-compact="true"][data-open="true"] .panel {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  animation: none !important;
}

.chat[data-compact="true"][data-open="true"] .panel-head {
  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}

.chat[data-compact="true"][data-open="true"] .log {
  margin: 0;
  padding: 10px 10px 6px;
  gap: 8px;
  width: 100%;
}

.chat[data-compact="true"][data-open="true"] .choices,
.chat[data-compact="true"][data-open="true"] .composer-shell,
.chat[data-compact="true"][data-open="true"] .composer-hint {
  width: 100%;
}

.chat[data-compact="true"][data-open="true"] .choices {
  margin: 0;
  padding-left: 10px;
  padding-right: 10px;
}

.chat[data-compact="true"][data-open="true"] .composer {
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
}

.chat[data-compact="true"][data-open="true"] .msg-row {
  width: fit-content;
  max-width: 100%;
  gap: 6px;
}

.chat[data-compact="true"][data-open="true"] .msg-stack {
  flex: 0 1 auto;
  width: auto;
  max-width: calc(100% - 30px);
  min-width: 0;
}

.chat[data-compact="true"][data-open="true"] .msg-avatar {
  width: 24px;
  height: 24px;
  font-size: 9px;
}

.chat[data-compact="true"][data-open="true"] .msg-row .bubble,
.chat[data-compact="true"][data-open="true"] .bubble {
  width: fit-content;
  max-width: 100%;
  padding: 9px 12px;
  font-size: 14px;
}

.chat[data-compact="true"][data-open="true"] .bubble.file-wrap {
  width: fit-content;
  max-width: 100%;
}

body:has(.chat[data-compact="true"][data-open="true"]) {
  overflow: hidden;
}

@media (max-width: 640px) {
  .chat:not([data-open="true"]) {
    right: 12px;
    bottom: 12px;
  }

  .stage {
    padding-top: 4vh;
  }
}
