:root {
  font-family: system-ui, sans-serif;
  color: #33302d;
  background: #f7f4ef;
  line-height: 1.6;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 4vw;
  border-bottom: 1px solid #ddd5ca;
  gap: 1rem;
  flex-wrap: wrap;
}
a {
  color: #604537;
}
h1,
h2 {
  font-family: serif;
  font-weight: 500;
}
h1 {
  font-size: clamp(2rem, 5vw, 3.3rem);
}
main {
  max-width: 1000px;
  margin: auto;
  padding: 2rem 1rem;
}
.brand {
  text-decoration: none;
  font-size: 1.4rem;
}
.brand small {
  font-size: 0.8rem;
  margin-left: 1rem;
}
nav {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.card,
form,
.message {
  background: #fffdf9;
  border: 1px solid #e1d9ce;
  border-radius: 12px;
  padding: 1.2rem;
  margin-bottom: 1rem;
}
button,
.button {
  background: #715444;
  color: white;
  border: 0;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button.secondary {
  background: #e5ddd3;
  color: #443a32;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
input,
textarea,
select {
  display: block;
  width: 100%;
  padding: 0.7rem;
  border: 1px solid #c8bfb4;
  border-radius: 6px;
  background: white;
  color: #333;
  font: inherit;
  margin: 0.3rem 0 1rem;
}
textarea {
  min-height: 100px;
}
label {
  font-size: 0.9rem;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #eee9e2;
  padding: 1rem;
  font-size: 0.8rem;
}
#notice:not(:empty) {
  padding: 0.8rem;
  background: #f4e2d0;
  margin-bottom: 1rem;
}
.message {
  white-space: pre-wrap;
}
.message.user {
  margin-left: 12%;
  background: #ece4da;
}
.message.character {
  margin-right: 12%;
}
.muted {
  color: #706b65;
}
.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
audio {
  max-width: 100%;
}
.composer {
  position: relative;
  background: #f7f4ef;
  padding-top: 0.5rem;
}
dialog {
  max-width: 600px;
  width: 95%;
  border: 1px solid #c8bfb4;
  border-radius: 12px;
}
.row {
  display: flex;
  gap: 1rem;
  align-items: center;
}
@media (max-width: 600px) {
  main {
    padding: 1rem;
  }
  .message.user,
  .message.character {
    margin-left: 0;
    margin-right: 0;
  }
  nav button {
    padding: 0.5rem;
  }
  .row {
    display: block;
  }
}

.chat-log {
  max-height: 65vh;
  overflow-y: auto;
  padding-top: 1rem;
}
.reply-suggestions {
  margin: 1rem 0;
}
.suggestion {
  padding: 0.75rem;
  margin: 0.5rem 0;
  border: 1px solid #b8b8b8;
  border-radius: 0.5rem;
  overflow-wrap: anywhere;
}

[hidden] {
  display: none;
}
button,
a,
summary,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}
:focus-visible {
  outline: 3px solid #487b74;
  outline-offset: 3px;
}
button:hover:not(:disabled),
.button:hover {
  filter: brightness(0.94);
}
button:disabled {
  cursor: not-allowed;
}
input[type="checkbox"] {
  display: inline-block;
  width: auto;
  margin: 0 0.6rem 0 0;
  accent-color: #715444;
}
label:has(> input[type="checkbox"]) {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  align-items: center;
  margin: 0.8rem 0;
  gap: 0.4rem;
}
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-heading h1,
.page-heading h2 {
  margin: 0;
}
.page-heading p {
  margin: 0.3rem 0;
}
.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: #786653;
  font-weight: 650;
}
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.list-toolbar input {
  max-width: 420px;
  margin: 0;
}
.list-toolbar span {
  flex-shrink: 0;
  font-size: 0.9rem;
}
.character-row {
  border: 1px solid #ded6cc;
  background: #fffdf9;
  border-radius: 12px;
  margin: 0 0 0.85rem;
  overflow: hidden;
}
.character-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  cursor: pointer;
  list-style: none;
}
.character-summary::-webkit-details-marker {
  display: none;
}
.character-summary::before {
  content: "›";
  font-size: 1.5rem;
  transition: transform 0.15s;
}
.character-row[open] > .character-summary::before {
  transform: rotate(90deg);
}
.character-summary > div {
  flex: 1;
  min-width: 0;
}
.character-summary h2 {
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 650;
  margin: 0;
}
.character-summary p {
  margin: 0.2rem 0 0;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}
.character-content {
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid #eee7df;
}
.status-pill {
  display: inline-block;
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  background: #eee8df;
  color: #685a4b;
}
.status-pill.active {
  color: #256252;
  background: #e4efe7;
}
.version-history {
  margin-top: 1.5rem;
}
.version-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid #eee7df;
  padding: 0.85rem 0;
}
.version-row small,
.issue-list small {
  display: block;
}
.version-row p {
  margin: 0.2rem 0;
}
.version-row button {
  flex-shrink: 0;
}
.conversion-report {
  margin-top: 1rem;
  font-size: 0.9rem;
}
summary {
  cursor: pointer;
}
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  border: 1px dashed #c8bfb4;
  border-radius: 12px;
  background: #fffdf9;
  color: #706b65;
}
.workbench-dialog {
  max-width: 850px;
  padding: 1.5rem;
  max-height: 92dvh;
  overflow-y: auto;
}
dialog::backdrop {
  background: rgb(36 30 25 / 45%);
  backdrop-filter: blur(3px);
}
.upload-form {
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
}
.upload-files {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0;
}
.drop-zone {
  padding: 1.1rem;
  border: 2px dashed #c8bfb4;
  border-radius: 12px;
  background: #faf7f2;
  min-width: 0;
}
.drop-zone.drag-over {
  border-color: #487b74;
  background: #e8f2ed;
}
.drop-zone input {
  font-size: 0.8rem;
  background: transparent;
  border: 0;
  padding: 0.4rem 0;
}
.drop-zone button {
  font-size: 0.75rem;
  padding: 0.3rem 0.5rem;
}
.drop-zone p {
  font-size: 0.85rem;
}
.file-chip {
  display: block;
  border-radius: 6px;
  background: #e9e2d7;
  padding: 0.3rem 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}
.inline-error {
  color: #963b30;
}
.issue-list {
  background: #fff0e9;
  border: 1px solid #efd0c2;
  padding: 1rem 1rem 1rem 2rem;
  border-radius: 8px;
  color: #893d31;
  overflow-wrap: anywhere;
}
.issue-list:empty {
  display: none;
}
.issue-list li + li {
  margin-top: 0.75rem;
}
.tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.35rem 0;
}
.tabs button {
  white-space: nowrap;
  background: transparent;
  border: 1px solid transparent;
  color: #6c6259;
}
.tabs button[aria-selected="true"] {
  background: #fffdf9;
  border-color: #d6cbbc;
  color: #4c3628;
  box-shadow: 0 2px 4px rgb(50 40 25 / 6%);
  font-weight: 650;
}
.primary-tabs {
  padding: 0.4rem;
  background: #ebe5db;
  border-radius: 12px;
  margin: 1.4rem 0;
}
.primary-tabs button {
  flex: 1;
}
.model-tabs {
  margin-bottom: 0.6rem;
  border-bottom: 1px solid #ded6cc;
}
.settings-title {
  font-size: 2rem;
  margin: 0.5rem 0 1rem;
}
/* Full provider URLs and native file controls must fit narrow settings panels. */
.settings-panels {
  overflow-wrap: anywhere;
}
.settings-panels input,
.settings-panels select,
.settings-panels textarea {
  min-width: 0;
  max-width: 100%;
}
.settings-panels small {
  display: block;
  overflow-wrap: anywhere;
}

.settings-panels fieldset {
  min-width: 0;
  border: 1px solid #ded6cc;
  border-radius: 12px;
  padding: 1.25rem;
  margin: 1rem 0;
  background: #fffdf9;
}
.settings-panels legend {
  font-weight: 650;
  padding: 0 0.5rem;
}
.settings-panels details {
  border-top: 1px solid #eee7df;
  padding-top: 1rem;
  margin-top: 1rem;
}
.model-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.model-actions button {
  font-size: 0.8rem;
  padding: 0.4rem 0.6rem;
}
.model-actions .status-pill {
  margin-right: auto;
}
.optional-service {
  padding: 1rem 0;
}
.settings-savebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  background: rgb(247 244 239 / 96%);
  border-top: 1px solid #d6cbbc;
  margin-top: 1.5rem;
}
.settings-savebar[hidden] {
  display: none;
}
.settings-savebar span {
  font-size: 0.85rem;
}
@media (max-width: 600px) {
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .workbench-dialog .page-heading {
    flex-direction: row;
  }
  .upload-files {
    grid-template-columns: 1fr;
  }
  .version-row {
    flex-wrap: wrap;
  }
  .character-summary {
    padding: 1rem;
  }
  .list-toolbar {
    flex-wrap: wrap;
  }
  .settings-savebar {
    flex-wrap: wrap;
  }
  .primary-tabs button {
    padding: 0.6rem;
  }
}

.field-help {
  color: #63594f;
  background: #f5f0e8;
  border-left: 3px solid #c8b8a4;
  border-radius: 4px;
  padding: 0.7rem 1rem;
  margin: -0.3rem 0 1.25rem;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
.field-help p {
  margin: 0 0 0.6rem;
}
.field-help p:last-child {
  margin-bottom: 0;
}

/* The chat shell owns the viewport; only its message area scrolls vertically. */
body.chat-mode {
  overflow: hidden;
  overscroll-behavior: none;
}
body.chat-mode > header {
  display: none;
}
body.chat-mode main {
  max-width: none;
  width: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
.chat-shell {
  position: fixed;
  top: var(--chat-top, 0px);
  left: 0;
  width: 100%;
  height: var(--chat-height, 100dvh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: #f7f4ef;
}
.chat-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: max(0.75rem, env(safe-area-inset-top)) 1.5rem 0.75rem;
  border-bottom: 1px solid #dfd6ca;
  background: #fffdf9;
  z-index: 5;
}
.chat-toolbar h1 {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 38px;
  height: 38px;
  padding: 8px;
  flex-shrink: 0;
  border-radius: 10px;
  background: transparent;
  color: #67584a;
}
.icon-button svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.chat-actions .icon-button {
  width: auto;
  font-size: 0.85rem;
  white-space: nowrap;
}
body.chat-mode #notice:not(:empty) {
  position: fixed;
  z-index: 30;
  top: calc(env(safe-area-inset-top) + 68px);
  right: 1rem;
  max-width: min(550px, calc(100vw - 2rem));
  border: 1px solid #d4bda6;
  border-radius: 10px;
  box-shadow: 0 4px 16px #332b2217;
  overflow-wrap: anywhere;
}
.chat-shell .chat-log {
  min-height: 0;
  max-height: none;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  padding: 1.5rem clamp(1rem, 3vw, 3rem);
  scroll-padding-bottom: 1rem;
  scrollbar-gutter: stable;
}
.chat-log > button {
  display: block;
  margin: 0 auto 1rem;
}
.chat-log .message {
  width: fit-content;
  max-width: min(85%, 85ch);
  margin: 0 0 1.2rem;
  padding: 0.9rem 1.15rem;
  border: 1px solid #e4dbcf;
  border-radius: 14px;
  background: #fffdf9;
  overflow-wrap: anywhere;
  white-space: normal;
}
.chat-log .message.user {
  margin-left: auto;
  background: #eae3d8;
  border-color: #dcd2c3;
}
.chat-log .message p {
  margin: 0.4rem 0 0;
  white-space: pre-wrap;
  line-height: 1.75;
}
.chat-log .message small {
  color: #7d6c5c;
  font-size: 0.75rem;
}
.chat-log .message button {
  margin-top: 0.6rem;
}
.chat-dock {
  position: relative;
  min-width: 0;
  z-index: 6;
  padding: 0.65rem clamp(0.75rem, 2vw, 2rem) max(0.8rem, env(safe-area-inset-bottom));
  border-top: 1px solid #e2d8ca;
  background: #f7f4ef;
}
.chat-dock .composer {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  min-width: 0;
}
.composer-input-box {
  position: relative;
  border: 1px solid #cfc1b0;
  background: #fffdf9;
  border-radius: 16px;
  box-shadow: 0 2px 8px #30271c08;
}
.composer-input-box:focus-within {
  border-color: #947b61;
  box-shadow: 0 0 0 2px #baa58c24;
}
.composer-input-box .message-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 0;
  max-height: none;
  margin: 0;
  padding: 10px 98px 10px 48px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  font-size: 16px;
  line-height: 24px;
  resize: none;
  outline: none;
  overflow-y: auto;
  scrollbar-width: none;
}
.message-input::-webkit-scrollbar {
  display: none;
}
.attach-button {
  position: absolute;
  left: 5px;
  bottom: 4px;
}
.composer-right {
  position: absolute;
  right: 5px;
  bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.composer-right .send-button {
  background: #715444;
  color: #fffdf9;
  border-radius: 50%;
}
.composer-right .send-button:disabled {
  background: #d4d0ca;
  color: #908a83;
  opacity: 1;
  cursor: not-allowed;
}
.composer-right .recording {
  color: #ad382f;
  background: #fae7e3;
}
.composer-right .cancel-recording {
  color: #b9362c;
  background: #fbeae6;
}
.attachment-tray {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.1rem 0 0.5rem;
  min-width: 0;
}
.attachment-preview {
  position: relative;
  flex: 0 0 84px;
  height: 82px;
  border: 1px solid #d8cbbd;
  border-radius: 9px;
  overflow: hidden;
  background: #ede7dd;
}
.attachment-preview > img,
.attachment-preview > video {
  width: 100%;
  height: 61px;
  object-fit: cover;
  display: block;
}
.attachment-preview > svg {
  display: block;
  height: 34px;
  width: 34px;
  margin: 13px auto 14px;
  color: #846951;
}
.attachment-preview > span {
  display: block;
  padding: 0 5px;
  font-size: 10px;
  line-height: 19px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-preview .icon-button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 24px;
  height: 24px;
  padding: 4px;
  color: #fff;
  background: #342a22ad;
  border-radius: 50%;
}
.voice-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.2rem 0 0.6rem;
  font-size: 0.85rem;
  color: #735b49;
}
.voice-preview audio {
  height: 32px;
  max-width: 240px;
  min-width: 0;
}
.chat-dock .reply-suggestions {
  position: absolute;
  bottom: calc(100% + 8px);
  left: clamp(0.75rem, 2vw, 2rem);
  right: clamp(0.75rem, 2vw, 2rem);
  margin: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid #dacebe;
  border-radius: 14px;
  background: rgb(255 253 249 / 97%);
  box-shadow: 0 6px 28px #44312120;
}
.suggestion-heading {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.suggestion-heading h2 {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  margin: 0;
}
.chat-dock .suggestion-heading small {
  color: #8c7b69;
  font-size: 0.75rem;
}
.suggestion-heading .icon-button {
  width: 28px;
  height: 28px;
  padding: 5px;
  margin-left: auto;
}
.suggestion-cards {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.35rem 0;
}
.suggestion-cards .suggestion {
  flex: 1 0 240px;
  min-width: 0;
  margin: 0;
  padding: 0.65rem 0.8rem;
  border: 1px solid #e6dccf;
  border-radius: 10px;
  background: #f8f3eb;
}
.suggestion > strong {
  font-size: 0.8rem;
  font-weight: 600;
  color: #74583f;
}
.suggestion .suggestion-text {
  font-size: 0.9rem;
  margin: 0.3rem 0 0.5rem;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
.suggestion-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.chat-dock .suggestion-buttons button {
  padding: 0.3rem 0.5rem;
  font-size: 0.75rem;
  background: #e9dfd0;
}
.suggestion-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
}
.chat-dock .suggestion-status p {
  margin: 0.4rem 0;
}
.chat-dock .suggestion-status > button {
  white-space: nowrap;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
}
.restore-suggestions {
  position: absolute;
  right: 1rem;
  bottom: calc(100% + 8px);
  box-shadow: 0 2px 9px #44312120;
  font-size: 0.8rem;
}
.chat-dialog {
  padding: 0;
  width: min(720px, calc(100vw - 2rem));
  max-width: none;
  max-height: calc(100dvh - 2rem);
  border-radius: 16px;
  background: #fffdf9;
}
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.2rem;
  border-bottom: 1px solid #dfd4c4;
  position: sticky;
  top: 0;
  background: #fffdf9;
  z-index: 1;
}
.dialog-heading h2 {
  margin: 0;
  font-size: 1.2rem;
}
.dialog-content {
  padding: 1.2rem;
  overflow-wrap: anywhere;
}
.dialog-media {
  display: block;
  max-width: 100%;
  max-height: 65dvh;
  margin: auto;
}
.memory-snippet {
  border-bottom: 1px solid #e9e0d3;
  padding: 0.8rem 0;
}
@media (max-width: 600px) {
  .chat-toolbar {
    padding: max(0.45rem, env(safe-area-inset-top)) 0.55rem 0.45rem;
    gap: 0.35rem;
  }
  .chat-toolbar h1 {
    font-size: 0.95rem;
  }
  .chat-actions {
    gap: 0.15rem;
  }
  .chat-actions .icon-button {
    width: 34px;
    height: 36px;
    padding: 7px;
  }
  .toolbar-label {
    display: none;
  }
  .chat-shell .chat-log {
    padding: 1rem 0.75rem;
  }
  .chat-log .message {
    max-width: 95%;
    padding: 0.8rem 0.9rem;
  }
  .chat-dock {
    padding-top: 0.4rem;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  }
  .suggestion-cards .suggestion {
    flex-basis: 220px;
  }
  .voice-preview {
    gap: 0.5rem;
    font-size: 0.75rem;
  }
  .voice-preview audio {
    flex: 1;
    max-width: 190px;
  }
  body.chat-mode #notice:not(:empty) {
    top: calc(env(safe-area-inset-top) + 52px);
  }
}
/* Components above use flex/grid; the hidden attribute must still remove them. */
.chat-shell.chat-shell [hidden] {
  display: none;
}

.chat-shell .chat-log {
  padding-bottom: calc(1rem + var(--suggestion-space, 0px));
}

.raw-model-response {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chat-log .send-status {
  display: block;
  margin-top: 0.5rem;
  opacity: 0.75;
}
.chat-log .send-failed .send-status {
  color: #a12a27;
  opacity: 1;
}

.character-library {
  align-items: start;
}
.character-card {
  min-width: 0;
  overflow-wrap: anywhere;
}
.character-card h3 {
  font-size: 0.95rem;
  margin: 1.25rem 0 0.5rem;
}
.character-stories {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.character-stories .story-link {
  width: 100%;
  text-align: left;
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  border: 1px solid #e1d9ce;
  background: #f7f4ef;
}
.story-link:hover {
  background: #ece4da;
}
.story-title {
  font-weight: 600;
}
.story-meta {
  font-size: 0.8rem;
  color: #706b65;
}

/* Same semantic emphasis/quote rules as ST; colors fit VComp's light background. */
.message-text {
  --message-emphasis: #706b65;
  --message-quote: #97521c;
  --message-underline: #775486;
  line-height: 1.75;
}
.chat-log .message .message-text p {
  white-space: normal;
}
.message-text em,
.message-text i {
  color: var(--message-emphasis);
}
.message-text q {
  color: var(--message-quote);
}
.message-text q em,
.message-text q i {
  color: inherit;
}
.message-text q::before,
.message-text q::after {
  content: "";
}
.message-text u {
  color: var(--message-underline);
}
.message-text blockquote {
  margin: 0.75rem 0;
  padding-left: 0.8rem;
  border-left: 3px solid #c8b5a4;
  color: #706b65;
}
.message-text pre {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre;
  overflow-wrap: normal;
}
.message-text code {
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
}
.message-text :not(pre) > code {
  padding: 0.1em 0.3em;
  background: #eee9e2;
  border-radius: 3px;
}
.message-text ul,
.message-text ol {
  padding-left: 1.5rem;
}
.message-text h1,
.message-text h2,
.message-text h3 {
  font-family: inherit;
  font-size: 1.2em;
  font-weight: 600;
}
.message-text .message-table {
  max-width: 100%;
  overflow-x: auto;
  margin-top: 0.5rem;
}
.message-text table {
  border-collapse: collapse;
}
.message-text th,
.message-text td {
  padding: 0.35rem 0.6rem;
  border: 1px solid #d4c8ba;
}
.message-text summary {
  cursor: pointer;
}

.settings-toast {
  position: fixed;
  z-index: 2000;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(640px, calc(100vw - 32px));
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 12px;
  color: #fff;
  background: #304b3e;
  box-shadow: 0 6px 24px #0003;
  overflow-wrap: anywhere;
}
.settings-toast.error {
  background: #79382d;
}
.settings-toast[hidden] {
  display: none;
}
.settings-toast .toast-close {
  padding: 0 4px;
  background: transparent;
  color: inherit;
  font-size: 24px;
  flex-shrink: 0;
}
.model-test-help {
  display: block;
  margin-top: 8px;
  color: var(--muted, #70665c);
}
