:root {
  font-family:
    system-ui,
    -apple-system,
    "PingFang SC",
    sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  color-scheme: light;
  --bg: #f7f9f5;
  --surface: #fffffc;
  --text: #293b35;
  --muted: #697c70;
  --line: #d9e3d6;
  --accent: #367359;
  --soft: #e7f0e6;
  --danger: #9d503b;
  --on-accent: #ffffff;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
main {
  padding: 18px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
button,
input,
textarea,
select {
  font: inherit;
}
button {
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  padding: 11px 16px;
  cursor: pointer;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
input,
textarea,
select {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  color: inherit;
  padding: 12px;
  min-width: 0;
}
label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}
input {
  width: 100%;
}
.spark {
  font-size: 32px;
  color: var(--accent);
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
}
h1 {
  font-size: 23px;
  line-height: 1.5;
  font-weight: 600;
}
#unlock-view > p {
  line-height: 1.8;
  color: var(--muted);
}
#unlock-view {
  padding: 8px 6px;
}
#unlock-form {
  margin-top: 22px;
}
#unlock-button {
  width: 100%;
  margin-top: 12px;
}
.hint {
  font-size: 12px;
}
#visitor-notice {
  font-size: 12px;
  line-height: 1.5;
  color: var(--danger);
  margin: 10px 0 0;
  overflow-wrap: anywhere;
  min-height: 0;
}
#visitor-notice:empty {
  display: none;
}
[hidden] {
  display: none !important;
}
#chat-view {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}
.toolbar,
.composer,
.chat-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.toolbar {
  font-size: 11px;
  color: var(--muted);
}
.toolbar button,
.chat-foot button {
  padding: 6px;
  background: transparent;
  color: var(--accent);
  white-space: nowrap;
}
#messages {
  flex: 1;
  overflow: auto;
  padding: 18px 0;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}
.welcome {
  color: var(--muted);
  line-height: 1.8;
  font-size: 14px;
}
.message {
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.8;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}
.message.user {
  background: var(--soft);
  margin-left: 24px;
  white-space: pre-wrap;
}
.message.model {
  background: var(--surface);
  border: 1px solid var(--line);
  margin-right: 8px;
}
.message p {
  margin: 0 0 8px;
}
.message p:last-child {
  margin-bottom: 0;
}
.message h1,
.message h2,
.message h3 {
  font-size: 16px;
  margin: 10px 0 6px;
}
.message ul,
.message ol {
  padding-left: 22px;
}
.message pre {
  background: var(--soft);
  padding: 10px;
  overflow: auto;
  border-radius: 8px;
  white-space: pre-wrap;
}
.message table {
  display: block;
  overflow: auto;
  border-collapse: collapse;
}
.message th,
.message td {
  border: 1px solid var(--line);
  padding: 6px;
}
.message a {
  color: var(--accent);
}
.message blockquote {
  margin: 8px 0;
  padding-left: 10px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}
#visitor-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  padding: 12px;
}
textarea {
  display: block;
  resize: none;
  width: 100%;
  border: 0;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
  line-height: 1.6;
  max-height: 100px;
  padding: 0;
}
textarea:focus-visible {
  outline: none;
}
.composer select {
  border: 0;
  background: var(--soft);
  font-size: 11px;
  padding: 9px 6px;
  flex: 1;
  max-width: 245px;
}
.composer button {
  white-space: nowrap;
  padding: 9px 13px;
}
.chat-foot {
  font-size: 10px;
  color: var(--muted);
  margin-top: 5px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.local-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 600;
}
.local-toolbar button {
  padding: 6px 9px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
}
.composer {
  justify-content: flex-end;
}
#history-notice {
  color: var(--danger);
  font-size: 12px;
}
#history-notice:empty {
  display: none;
}
#history-dialog {
  width: calc(100% - 24px);
  max-width: 580px;
  max-height: 85dvh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: inherit;
  background: var(--bg);
  padding: 18px;
}
#history-dialog::backdrop {
  background: #162d2466;
}
.history-row {
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
.history-row button {
  padding: 9px;
  background: transparent;
  color: var(--accent);
}
.history-title {
  flex: 1;
  min-width: 0;
  text-align: left;
  overflow-wrap: anywhere;
}
.history-title small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #171d1b;
    --surface: #202622;
    --text: #deebe1;
    --muted: #a0b2a5;
    --line: #404d44;
    --accent: #8fc7a6;
    --soft: #2b3b31;
    --danger: #ef9c8e;
    --on-accent: #17281d;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171d1b;
  --surface: #202622;
  --text: #deebe1;
  --muted: #a0b2a5;
  --line: #404d44;
  --accent: #8fc7a6;
  --soft: #2b3b31;
  --danger: #ef9c8e;
  --on-accent: #17281d;
}

:root[data-embedded="true"] main {
  padding: 12px 16px;
}
:root[data-embedded="true"] .local-toolbar {
  display: none;
}
:root[data-embedded="true"] .toolbar {
  justify-content: flex-end;
  gap: 12px;
}
:root[data-embedded="true"] #expiry {
  margin-right: auto;
  font-size: 10px;
}
:root[data-embedded="true"] #messages {
  padding: 14px 0;
}
:root[data-embedded="true"] button {
  border-radius: 8px;
}
:root[data-embedded="true"] #visitor-chat {
  border-radius: 12px;
}
textarea::placeholder,
input::placeholder {
  color: var(--muted);
  opacity: 1;
}
#visitor-chat:focus-within {
  border-color: var(--accent);
}

/* Public website palette; native clients retain their own matching palette. */
:root[data-skin="web"] {
  --bg: #faf6eb;
  --surface: #faf6eb;
  --text: #244c67;
  --muted: #627680;
  --line: #ccd4ce;
  --accent: #244c67;
  --soft: #eee8dc;
  --danger: #a34531;
  --on-accent: #faf6eb;
}
:root[data-skin="web"][data-theme="dark"] {
  --bg: #1e2932;
  --surface: #202f35;
  --text: #cfdfeb;
  --muted: #a0b3bc;
  --line: #465965;
  --accent: #9ec4db;
  --soft: #2b3e49;
  --danger: #f0a18a;
  --on-accent: #151d24;
}

/* Compact conversation layout shared by the web panel and native sidebar. */
main,
:root[data-embedded="true"] main {
  padding: 8px 12px;
}
#unlock-view {
  padding: 8px 0;
  overflow: auto;
}
#unlock-view h1 {
  font-size: 20px;
  margin: 4px 0 10px;
}
#unlock-view > p {
  margin: 8px 0;
  line-height: 1.6;
}
#unlock-form {
  margin-top: 16px;
}
#messages,
:root[data-embedded="true"] #messages {
  padding: 10px 0;
  min-height: 0;
}
.message {
  padding: 8px 10px;
  line-height: 1.65;
  margin-bottom: 10px;
}
.message.model {
  border: 0;
  background: transparent;
  margin-right: 0;
  padding: 6px 0;
}
.message ul,
.message ol {
  padding-left: 20px;
  margin: 8px 0;
}
#visitor-chat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 3px 8px;
  padding: 8px 10px;
}
#visitor-chat textarea {
  grid-column: 1;
  grid-row: 1;
  flex: 1;
  min-height: 30px;
  padding: 4px 0;
}
#visitor-chat .composer {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  flex: none;
}
.composer button {
  padding: 8px 10px;
}
.chat-foot {
  margin-top: 3px;
}
.reply-waiting {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
}
.reply-waiting span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: reply-pulse 1.2s ease-in-out infinite;
}
.reply-waiting span:nth-child(2) {
  animation-delay: 0.16s;
}
.reply-waiting span:nth-child(3) {
  animation-delay: 0.32s;
}
@keyframes reply-pulse {
  0%,
  70%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-3px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .reply-waiting span {
    animation: none;
    opacity: 0.7;
  }
}
@media (pointer: coarse) {
  #access-key,
  #prompt {
    font-size: 16px;
  }
}

#composer-hint {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  pointer-events: none;
  font-size: 10px;
  line-height: 1.4;
  color: var(--muted);
  padding: 0 0 1px;
}
:root[data-embedded="true"] .toolbar {
  gap: 6px;
  flex-wrap: wrap;
}
#chat-view .toolbar #expiry {
  min-width: 0;
}

#prompt:focus ~ #composer-hint,
#prompt:not(:placeholder-shown) ~ #composer-hint {
  visibility: hidden;
}

.product-language {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 10px;
  padding: 7px 10px;
  max-width: 150px;
  min-width: 0;
}
@media (max-width: 600px) {
  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .product-language {
    font-size: 13px;
    max-width: 125px;
  }
  .heading h2 {
    overflow-wrap: anywhere;
  }
}
