.backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(2px);
  animation: backdrop-soft-in 180ms ease-out both;
}

.side-panel,
.bottom-panel {
  position: fixed;
  z-index: 40;
  background: var(--panel);
  box-shadow: var(--shadow);
  will-change: transform, opacity;
}

.side-panel {
  top: 0;
  bottom: 0;
  width: min(88vw, 390px);
  padding: max(env(safe-area-inset-top), 14px) 16px 18px;
  overflow-y: auto;
}

.left-panel {
  left: 0;
  animation: panel-left-in var(--motion-spring) both;
}

.right-panel {
  right: 0;
  animation: panel-right-in var(--motion-spring) both;
}

.bottom-panel {
  right: max(8px, calc((100vw - 820px) / 2 + 8px));
  bottom: 8px;
  left: max(8px, calc((100vw - 820px) / 2 + 8px));
  max-height: 76dvh;
  padding: 14px;
  overflow: auto;
  border-radius: 18px;
  transform-origin: 50% 100%;
  animation: panel-bottom-in var(--motion-spring) both;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head strong {
  font-size: 20px;
  font-weight: 600;
}

.panel-row,
.split-fields {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.field {
  display: grid;
  gap: 7px;
  margin: 13px 0;
  color: #555;
  font-size: 15px;
}

.field input,
.field textarea,
.plain-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #555;
  font-size: 15px;
}

.settings-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.range-field {
  display: grid;
  gap: 5px;
  margin: 10px 0;
  color: #555;
  font-size: 14px;
}

.range-field span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.range-field b {
  color: #222;
  font-weight: 500;
}

.range-field input {
  width: 100%;
}

.preset-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.preset-row button {
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f7f7;
  font-size: 13px;
}

.compact-field {
  margin-top: 12px;
}

.custom-preset-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.custom-preset-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.custom-preset-item button {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.novel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: -5px 0 12px;
}

.novel-actions button {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f7f7;
  color: #333;
  font-size: 13px;
}

.novel-version-list,
.novel-segment-list {
  display: grid;
  gap: 8px;
  margin: -2px 0 14px;
}

.novel-version-head,
.novel-version-item,
.novel-segment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.novel-version-head {
  color: var(--muted);
  font-size: 12px;
}

.novel-version-item,
.novel-segment-item {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fafafa;
}

.novel-segment-item.is-stale {
  border-style: dashed;
  background: #fff8ec;
}

.novel-version-item div:first-child,
.novel-segment-item div:first-child {
  min-width: 0;
}

.novel-version-item b,
.novel-version-item small,
.novel-segment-item b,
.novel-segment-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.novel-version-item b,
.novel-segment-item b {
  color: var(--text);
  font-size: 13px;
}

.avatar-setting-row,
.background-setting-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
}

.avatar-preview {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: #fff;
  background: #3b352d;
  font-weight: 800;
}

.avatar-preview img,
.background-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.background-preview {
  width: 86px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(135deg, #f7f3ea, #e7edf0);
  background-position: center;
  background-size: cover;
}

.background-preview.empty::after {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  content: "无";
  font-size: 13px;
}

.avatar-setting-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.avatar-setting-actions button,
#fetchAssistantModelsButton {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f7f7f7;
  font-size: 13px;
}

.novel-version-item small,
.novel-segment-item small {
  color: var(--muted);
  font-size: 11px;
}

.novel-version-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.novel-version-actions button {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 12px;
}

.primary-button,
.panel-row button,
.dialog-actions button {
  position: relative;
  overflow: hidden;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f7f7f7;
  transition:
    background-color var(--motion-fast),
    border-color var(--motion-fast),
    color var(--motion-fast),
    box-shadow var(--motion-fast),
    scale var(--motion-fast);
}

.primary-button:hover,
.panel-row button:hover,
.dialog-actions button:hover {
  box-shadow: var(--motion-press-shadow);
}

.primary-button {
  color: #fff;
  border-color: #222;
  background: #222;
}

.primary-button.ghost {
  color: #222;
  background: #fff;
}

.session-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.session-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.session-main {
  min-width: 0;
  text-align: left;
}

.session-main strong,
.session-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-main span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.session-actions {
  display: flex;
  gap: 4px;
}

.session-actions button {
  padding: 6px 7px;
  border-radius: 7px;
  color: #666;
  font-size: 13px;
}

.context-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.context-stats span {
  padding: 6px 9px;
  border-radius: 99px;
  background: #f3f3f3;
  color: #555;
  font-size: 13px;
}

.context-preview {
  max-height: 52dvh;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #333;
  font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

.roundtable-panel {
  display: grid;
  gap: 12px;
  border: 1px solid #eee5d5;
  background: #fffaf0;
}

.roundtable-head {
  margin-bottom: 2px;
}

.roundtable-head > div {
  display: grid;
  gap: 3px;
}

.roundtable-stage {
  display: grid;
  justify-items: center;
  gap: 13px;
}

.roundtable-paper {
  width: min(100%, 420px);
  min-height: 138px;
  padding: 18px 18px 20px;
  border: 1px solid #e4d8c0;
  background: linear-gradient(180deg, #fffef9 0%, #fff9eb 100%);
  box-shadow: 0 14px 28px rgba(77, 56, 26, 0.12);
}

.paper-kicker {
  margin-bottom: 10px;
  color: #8a7551;
  font-size: 12px;
  letter-spacing: 0;
}

.roundtable-paper p {
  margin: 0;
  color: #2c2822;
  font-size: 17px;
  line-height: 1.72;
}

.roundtable-beta-copy {
  width: 100%;
  padding: 10px 11px;
  border: 1px dashed #dccda9;
  background: rgba(255, 255, 255, 0.58);
}

.roundtable-beta-copy span {
  display: block;
  margin-bottom: 4px;
  color: #6b5936;
  font-size: 13px;
  font-weight: 700;
}

.roundtable-beta-copy p {
  margin: 0;
  color: #5f5a51;
  font-size: 13px;
  line-height: 1.55;
}

.roundtable-members {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  width: 100%;
}

.member-chip {
  display: inline-grid;
  place-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #ded2bb;
  border-radius: 8px;
  color: #5f574a;
  background: #fff;
  font-size: 13px;
}

.member-chip.selected {
  border-color: #b99b5e;
  color: #2c2417;
  background: #fff1cf;
  font-weight: 700;
}

.more-chip {
  min-width: 42px;
}

.roundtable-chat-preview {
  display: grid;
  gap: 8px;
  width: 100%;
}

.roundtable-chat-preview p {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 8px;
  align-items: start;
  margin: 0;
  color: #333;
  font-size: 14px;
  line-height: 1.55;
}

.roundtable-chat-preview b {
  color: #766348;
  font-weight: 700;
}

.writer-snippet {
  display: block;
  padding: 9px 10px;
  border-left: 3px solid #b99b5e;
  background: #fffdf7;
}

.roundtable-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.roundtable-actions button {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.edit-dialog {
  width: min(92vw, 680px);
  border: 0;
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  animation: dialog-rise var(--motion-spring) both;
}

.edit-dialog::backdrop {
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(2px);
}

.edit-dialog textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  padding: 12px;
  font-size: 17px;
  line-height: 1.55;
}

.assistant-config-dialog input[type="text"],
.assistant-config-dialog input[type="password"],
.assistant-config-dialog input[type="number"],
.assistant-config-dialog select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
}

.assistant-config-dialog input[type="range"] {
  width: 100%;
}

.assistant-config-dialog textarea {
  min-height: 210px;
}

#assistantActivationProfileInput {
  min-height: 150px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 250, 242, 0.98));
}

.assistant-fold {
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.assistant-fold summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  list-style: none;
  cursor: pointer;
}

.assistant-fold summary::-webkit-details-marker {
  display: none;
}

.assistant-fold summary::after {
  content: "展开";
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.assistant-fold[open] summary {
  border-bottom: 1px solid var(--line);
}

.assistant-fold[open] summary::after {
  content: "收起";
}

.assistant-fold > .field,
.assistant-fold > .assistant-context-head,
.assistant-fold > .assistant-context-options,
.assistant-fold > .assistant-context-numbers,
.assistant-fold > .assistant-activation-actions,
.assistant-fold > .assistant-model-picker-row,
.assistant-fold > .assistant-model-picker {
  margin-inline: 12px;
}

.assistant-fold > .field:first-of-type,
.assistant-fold > .assistant-context-head {
  margin-top: 12px;
}

.assistant-fold > .field:last-child,
.assistant-fold > .assistant-context-numbers,
.assistant-fold > .assistant-activation-actions,
.assistant-fold > .assistant-model-picker {
  margin-bottom: 12px;
}

.assistant-activation-actions {
  justify-content: flex-start;
}

.assistant-model-picker-row {
  display: flex;
  margin-top: -6px;
  margin-bottom: 10px;
}

.assistant-model-picker-row button {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #4c4237;
  background: #faf8f4;
  font-size: 13px;
  font-weight: 700;
}

.assistant-model-picker-row button.active {
  border-color: rgba(141, 107, 49, 0.34);
  background: var(--surface-selected);
}

.assistant-model-picker {
  display: grid;
  gap: 5px;
  max-height: 230px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 7px;
  border: 1px solid rgba(226, 220, 211, 0.95);
  border-radius: 12px;
  background: rgba(255, 253, 249, 0.96);
}

.assistant-model-picker[hidden] {
  display: none;
}

.assistant-model-picker button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 8px 9px;
  border-radius: 10px;
  color: #332f29;
  text-align: left;
}

.assistant-model-picker button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-model-picker button b {
  color: #8d6b31;
  font-size: 12px;
}

.assistant-model-picker button.selected {
  background: var(--surface-selected);
  font-weight: 800;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 12px;
}

.assistant-context-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 12px;
}

.assistant-context-head {
  display: grid;
  gap: 2px;
  margin: 12px 0 8px;
}

.assistant-context-head strong {
  color: var(--text);
  font-size: 14px;
}

.assistant-context-numbers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.assistant-context-options label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

@media (max-width: 420px) {
  .assistant-context-options,
  .assistant-context-numbers {
    grid-template-columns: 1fr;
  }
}

@keyframes backdrop-soft-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes panel-left-in {
  from {
    opacity: 0;
    transform: translateX(-18px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes panel-right-in {
  from {
    opacity: 0;
    transform: translateX(18px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes panel-bottom-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes dialog-rise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-pop {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(8px) scale(0.96);
  }

  72% {
    opacity: 1;
    transform: translateX(-50%) translateY(-1px) scale(1.02);
  }

  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--composer-height) + 28px);
  z-index: 90;
  max-width: 86vw;
  padding: 9px 13px;
  border-radius: 999px;
  color: #fff;
  background: rgba(0, 0, 0, 0.8);
  transform: translateX(-50%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
}

.toast.toast-pop {
  animation: toast-pop 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.stream-caret {
  display: inline-block;
  width: 8px;
  height: 1.1em;
  margin-left: 2px;
  opacity: 0.45;
  vertical-align: -0.18em;
  background: #222;
}

@media (min-width: 821px) {
  .messages {
    border-inline: 1px solid var(--line);
  }
}

/* Clean writing-desk adaptation for roundtable and manuscript controls. */
.novel-version-item,
.novel-segment-item {
  border-color: rgba(228, 224, 217, 0.95);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
}

.novel-segment-item.is-stale {
  background: rgba(255, 250, 240, 0.82);
}

.novel-version-actions button,
.roundtable-actions button {
  border-color: var(--line);
  border-radius: 9px;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.8);
}

.roundtable-panel {
  border-color: var(--line);
  background: linear-gradient(180deg, rgba(248, 246, 241, 0.98), rgba(246, 245, 241, 0.98));
}

.roundtable-paper {
  border-color: var(--surface-paper-edge);
  border-radius: 0 0 14px 14px;
  background:
    linear-gradient(90deg, rgba(173, 166, 151, 0.14) 1px, transparent 1px) 34px 0 / 1px 100% no-repeat,
    linear-gradient(180deg, #fffefd 0%, var(--surface-paper) 100%);
  box-shadow: var(--paper-shadow);
}

.roundtable-beta-copy {
  border-color: rgba(221, 215, 204, 0.86);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.58);
}

.member-chip {
  border-color: var(--line);
  border-radius: 9px;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.82);
}

.member-chip.selected {
  border-color: var(--text);
  color: var(--text);
  background: var(--surface-selected);
}

.writer-snippet {
  border-left-color: var(--surface-paper-edge);
  background: var(--surface-paper);
}

.assistant-config-dialog input[type="text"],
.assistant-config-dialog input[type="password"],
.assistant-config-dialog input[type="number"],
.assistant-config-dialog select,
.edit-dialog textarea {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.96);
}
