:root {
  --chx-bg: #f3e7dc;
  --chx-bg-soft: rgba(255, 248, 238, 0.82);
  --chx-surface: rgba(255, 251, 246, 0.82);
  --chx-surface-2: rgba(244, 237, 245, 0.72);
  --chx-line: rgba(112, 82, 151, 0.14);
  --chx-line-strong: rgba(112, 82, 151, 0.22);
  --chx-text: #251b31;
  --chx-text-soft: #7f6f8d;
  --chx-accent: #7b5a9d;
  --chx-accent-deep: #4f356f;
  --chx-gold: #a97838;
  --chx-green: #567b59;
  --chx-violet: #7561a4;
  --chx-chip-bg: #f3ece3;
  --chx-right-bubble: #8b5a3c;
  --chx-right-bubble-deep: #7a4d31;
}

.chx-chat-screen {
  background:
    radial-gradient(circle at 15% 12%, rgba(255, 226, 157, 0.42), transparent 30%),
    radial-gradient(circle at 86% 18%, rgba(173, 148, 255, 0.3), transparent 34%),
    linear-gradient(160deg, #fff7eb 0%, var(--chx-bg) 48%, #dbcacb 100%) !important;
}

.chx-chat-page,
.chx-chat-page * {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.chx-chat-page {
  height: 100%;
}

.chx-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--chx-line);
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 226, 157, 0.28), transparent 38%),
    linear-gradient(135deg, rgba(255, 250, 242, 0.9), rgba(236, 224, 236, 0.78));
  flex-shrink: 0;
}

.chx-icon-btn,
.chx-topbar-action {
  flex-shrink: 0;
}

.chx-topbar .back-btn {
  background: var(--chx-surface);
  border: 1px solid var(--chx-line);
  box-shadow: none;
}

.chx-topbar-title {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chx-topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 6px;
}

.chx-topbar-title strong {
  font-size: 16px;
  color: var(--chx-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chx-topbar-title span {
  font-size: 12px;
  color: var(--chx-text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chx-topbar-action {
  border: 1px solid var(--chx-line);
  background: var(--chx-surface);
  color: var(--chx-accent-deep);
  border-radius: 14px;
  padding: 8px 12px;
  min-width: 52px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.chx-topbar-action.secondary {
  background: transparent;
  color: var(--chx-text-soft);
}

.chx-main-content {
  display: flex;
  flex-direction: column;
  padding: 10px 12px 14px;
  gap: 10px;
  height: calc(100% - 56px);
  min-height: 0;
}

.chx-chat-view {
  flex: 1;
  min-height: 0;
  display: flex;
}

.chx-chat-main {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    radial-gradient(circle at 14% 10%, rgba(255, 231, 173, 0.28), transparent 32%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.76), rgba(246, 237, 247, 0.68)),
    var(--chx-surface);
  border: 1px solid var(--chx-line);
  border-radius: 24px;
  padding: 12px;
  box-shadow: 0 22px 52px rgba(55, 36, 82, 0.13);
  position: relative;
  overflow: hidden;
}

.chx-chat-statusbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chx-status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--chx-chip-bg);
  color: var(--chx-text);
  border: 1px solid var(--chx-line);
  font-size: 12px;
  font-weight: 700;
}

.chx-status-chip.muted {
  color: var(--chx-text-soft);
}

.chx-status-chip.active {
  background: #ece3d8;
  color: var(--chx-accent-deep);
}

.chx-status-chip.waiting {
  background: #f3e7d6;
  color: #9a6a2d;
}

.chx-status-chip.gold {
  background: #f3e6d2;
  color: #8a5f22;
}

.chx-status-chip.green {
  background: #e7f0e7;
  color: #446b47;
}

.chx-status-chip.violet {
  background: #ede8f8;
  color: #624f92;
}

.chx-chat-messages {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 2px;
  padding-bottom: 4px;
}

.chx-message-content-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: min(72vw, 280px);
  position: relative;
}

.chx-empty-chat {
  flex: 1;
  min-height: 300px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--chx-text-soft);
  gap: 6px;
}

.chx-empty-chat strong {
  display: block;
  color: var(--chx-text);
  font-size: 15px;
}

.chx-empty-chat span {
  font-size: 12px;
}

.chx-row {
  display: flex;
  width: 100%;
  align-items: flex-start;
  gap: 12px;
}

.chx-row.right {
  justify-content: flex-end;
}

.chx-row.left {
  justify-content: flex-start;
}

.chx-row.system {
  justify-content: center;
}

.chx-row.right .chx-avatar {
  order: 2;
}

.chx-row.right .chx-message-content-wrap,
.chx-row.right .chx-bubble {
  order: 1;
}

.chx-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  background: #f5f5f5;
  border: none;
}

.chx-bubble {
  position: relative;
  display: block;
  max-width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.6;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  box-shadow: none;
}

.chx-row.right .chx-bubble {
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 231, 173, 0.18), transparent 34%),
    linear-gradient(135deg, #6b4a8d, #3e2a5a);
  color: #fff8ee;
  border: 1px solid rgba(255, 236, 188, 0.16);
  border-radius: 18px 18px 6px 18px;
  box-shadow: 0 14px 26px rgba(63, 42, 90, 0.18);
}

.chx-row.left .chx-bubble {
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 231, 173, 0.28), transparent 34%),
    linear-gradient(135deg, rgba(255, 252, 247, 0.92), rgba(244, 236, 247, 0.86));
  color: #2f2440;
  border: 1px solid rgba(112, 82, 151, 0.14);
  border-radius: 18px 18px 18px 6px;
  box-shadow: 0 12px 24px rgba(65, 44, 91, 0.08);
}

.chx-row.left .chx-message-content-wrap {
  align-items: flex-start;
}

.chx-row.right .chx-message-content-wrap {
  align-items: flex-end;
}

.chx-bubble.card-reply {
  cursor: pointer;
  background: linear-gradient(180deg, #fffaf4 0%, #f3e8da 100%) !important;
  border: 1px solid rgba(123, 80, 51, 0.12) !important;
  color: var(--chx-accent-deep) !important;
}

.chx-bubble-timestamp {
  align-self: flex-end;
  margin-top: -2px;
  color: rgba(100, 116, 139, 0.72);
  font-size: 10px;
  line-height: 1;
  pointer-events: none;
}

.chx-row.left .chx-bubble-timestamp {
  align-self: flex-start;
}

.chx-bubble-quote {
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(157, 168, 173, 0.12);
  border-left: 3px solid #9da8ad;
  font-size: 12px;
  line-height: 1.45;
  color: #58656d;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chx-bubble-favorite {
  align-self: flex-end;
  font-size: 12px;
  color: #b28a54;
  line-height: 1;
}

.chx-row.left .chx-bubble-favorite {
  align-self: flex-start;
}

.chx-bubble p,
.chx-system-bubble span {
  font-size: 13px;
  line-height: 1.6;
}

.chx-bubble p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
}

.chx-bubble em,
.chx-system-bubble em {
  display: block;
  margin-top: 7px;
  font-style: normal;
  font-size: 11px;
  opacity: 0.66;
}

.chx-system-bubble {
  max-width: 84%;
  padding: 8px 12px;
  border-radius: 14px;
  background: #f2eadf;
  border: 1px solid var(--chx-line);
  text-align: center;
  color: var(--chx-text-soft);
}

.chx-plus-menu {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 72px;
  background: var(--chx-surface);
  border: 1px solid var(--chx-line);
  border-radius: 18px;
  padding: 12px;
  box-shadow: none;
  z-index: 12;
}

.chx-plus-grid,
.chx-deck-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.chx-plus-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.chx-plus-item {
  border: 1px solid var(--chx-line);
  background: #fcf8f3;
  border-radius: 16px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: none;
}

.chx-plus-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #efe4d6;
  color: var(--chx-accent-deep);
  font-size: 18px;
  font-weight: 700;
}

.chx-plus-item small {
  font-size: 12px;
  color: var(--chx-text);
  font-weight: 700;
}

.chx-compose-quote-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 251, 245, 0.9);
  border: 1px solid #e5ddd1;
}

.chx-compose-quote-text {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  line-height: 1.4;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chx-compose-quote-clear {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  width: auto;
  height: auto;
  border-radius: 0;
}

.chx-inputbar {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  padding-top: 2px;
  border-top: 1px solid rgba(74, 50, 33, 0.08);
}

.chx-circle-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--chx-line);
  background: var(--chx-surface);
  border-radius: 14px;
  color: var(--chx-accent-deep);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.chx-message-input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--chx-line-strong);
  border-radius: 14px;
  background: #fffdf9;
  padding: 0 14px;
  font-size: 13px;
  color: var(--chx-text);
  outline: none;
}

.chx-message-input:focus {
  border-color: rgba(123, 80, 51, 0.34);
  box-shadow: none;
}

.chx-send-btn {
  border: 1px solid rgba(96, 60, 37, 0.2);
  background: var(--chx-right-bubble);
  color: #fffaf4;
  border-radius: 14px;
  padding: 0 16px;
  height: 42px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.gxj-modal-mask {
  position: absolute;
  inset: 0;
  z-index: 40;
}

.chx-modal-card {
  background: var(--chx-surface);
  border: 1px solid var(--chx-line);
  box-shadow: none;
}

.chx-modal-tip {
  padding: 10px 12px;
  border-radius: 14px;
  background: #f4ede4;
  color: var(--chx-text-soft);
  font-size: 12px;
  line-height: 1.6;
}

.chx-reading-modal-card {
  max-width: min(100%, 420px);
}

.chx-records-modal-card {
  width: min(100%, 420px);
  max-height: min(82vh, 720px);
  display: flex;
  flex-direction: column;
}

.chx-record-detail-modal-card {
  width: min(100%, 460px);
  max-height: min(82vh, 720px);
  display: flex;
  flex-direction: column;
}

.chx-records-list,
.chx-record-detail-body {
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.chx-records-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chx-record-empty {
  display: grid;
  gap: 6px;
  padding: 18px 14px;
  border-radius: 16px;
  background: #fcf8f3;
  border: 1px dashed var(--chx-line-strong);
  text-align: center;
  color: var(--chx-text-soft);
}

.chx-record-empty strong {
  font-size: 14px;
  color: var(--chx-text);
}

.chx-record-empty span {
  font-size: 12px;
  line-height: 1.6;
}

.chx-record-item {
  width: 100%;
  border: 1px solid var(--chx-line);
  border-radius: 16px;
  background: #fcf8f3;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  cursor: pointer;
}

.chx-record-item-head,
.chx-record-item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chx-record-item-head strong {
  font-size: 13px;
  color: var(--chx-text);
}

.chx-record-item-head span,
.chx-record-item-foot span {
  font-size: 11px;
  color: var(--chx-text-soft);
}

.chx-record-item-text {
  font-size: 12px;
  line-height: 1.6;
  color: var(--chx-text);
  word-break: break-word;
}

.chx-record-detail-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chx-record-line {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chx-record-line label {
  font-size: 11px;
  color: var(--chx-text-soft);
}

.chx-record-line.right {
  align-items: flex-end;
}

.chx-record-line.left,
.chx-record-line.system {
  align-items: flex-start;
}

.chx-record-line-bubble {
  width: fit-content;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f7f7f7;
  border: 1px solid #dddddd;
}

.chx-record-line.right .chx-record-line-bubble {
  background: #111111;
  color: #ffffff;
  border-color: #111111;
}

.chx-record-line.system .chx-record-line-bubble {
  background: #f2eadf;
  border-color: var(--chx-line);
  color: var(--chx-text-soft);
}

.chx-record-line-bubble p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  font-size: 12px;
}

.chx-reading-form {
  gap: 12px;
}

.chx-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fcf8f3;
  border: 1px solid var(--chx-line);
  box-shadow: none;
  cursor: pointer;
}

.chx-switch-row span {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chx-switch-row strong {
  font-size: 13px;
  color: var(--chx-text);
}

.chx-switch-row small {
  font-size: 11px;
  color: var(--chx-text-soft);
  line-height: 1.5;
}

.chx-switch-input {
  appearance: none;
  -webkit-appearance: none;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: #d9cbbb;
  border: 1px solid rgba(66, 46, 30, 0.12);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.chx-switch-input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fffdf9;
  box-shadow: none;
  transition: transform 0.2s ease;
}

.chx-switch-input:checked {
  background: var(--chx-right-bubble);
  border-color: rgba(96, 60, 37, 0.4);
}

.chx-switch-input:checked::after {
  transform: translateX(18px);
}

.chx-switch-input:focus-visible {
  outline: none;
  box-shadow: none;
}

.chx-reading-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chx-modal-submit {
  width: 100%;
}

#gxjMessageActionMask {
  background: transparent;
}

.chx-message-action-sheet {
  position: fixed;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(17, 17, 17, 0.1);
  box-shadow: 0 14px 30px rgba(17, 17, 17, 0.12);
  z-index: 120;
  max-width: calc(100vw - 20px);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.chx-message-action-sheet::-webkit-scrollbar {
  display: none;
}

.chx-message-action-grid {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.chx-message-action-btn {
  border: none;
  border-radius: 999px;
  padding: 8px 12px;
  background: transparent;
  color: #111111;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.chx-message-action-btn:hover {
  background: #f2f2f2;
  color: #111111;
}

.chx-message-action-btn.danger {
  color: #8f7558;
  background: transparent;
}

.chx-message-action-btn.danger:hover {
  background: #f5f5f5;
  color: #8f7558;
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .chx-main-content {
    padding: 8px 10px 12px;
    height: calc(100% - 54px);
  }

  .chx-chat-main {
    border-radius: 18px;
    padding: 10px;
  }

  .chx-plus-grid,
  .chx-plus-grid.compact,
  .chx-deck-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .chx-row .chx-bubble,
  .chx-row .chx-message-content-wrap {
    max-width: calc(100% - 56px);
  }

  .chx-avatar {
    width: 38px;
    height: 38px;
  }

  .chx-topbar-actions {
    gap: 6px;
    margin-left: 4px;
  }

  .chx-topbar-action {
    min-width: 48px;
    padding: 8px 10px;
  }
}
