:root {
  --bg: #e7ebf0;
  --wechat-green: #07c160;
  --wechat-green-dark: #05a350;
  --text: #202b35;
  --sub: #6a7886;
  --line: #d6dce3;
  --white: #fff;
  --danger: #c3362f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 15% 0%, #f6faff 0%, #e8edf4 45%, #dfe5ee 100%);
}

body {
  min-height: 100dvh;
}

.app-shell {
  min-height: 100dvh;
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #f8f9fb 0%, #edf2f7 100%);
}

.admin-shell {
  min-height: 100dvh;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: #f4f8fc;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  background: linear-gradient(120deg, var(--wechat-green-dark) 0%, var(--wechat-green) 100%);
}

.top-bar__title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.top-bar__actions {
  display: flex;
  gap: 6px;
}

.top-bar--admin {
  position: static;
}

.guide-wrap {
  padding: 10px 10px 6px;
  border-bottom: 1px solid #d8e0ea;
  background: #f6f9fd;
}

.guide-title {
  font-size: 12px;
  color: #607084;
  margin-bottom: 8px;
}

.guide-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.guide-chip {
  border: 1px solid #c8d6e6;
  border-radius: 999px;
  background: #fff;
  color: #2e4458;
  font-size: 12px;
  padding: 7px 12px;
  white-space: nowrap;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
}

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
}

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

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--white);
}

.bubble {
  max-width: min(88vw, 620px);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid var(--line);
  background: var(--white);
  word-break: break-word;
  overflow-x: auto;
}

.msg-row--user .bubble {
  background: #95ec69;
  border-color: #7ed45f;
}

.bubble pre {
  background: #f3f7fb;
  border-radius: 10px;
  padding: 8px;
  white-space: pre-wrap;
}

.bubble code {
  font-family: "JetBrains Mono", "Consolas", monospace;
  font-size: 12px;
}

.bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  min-width: 420px;
}

.bubble img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 8px 0;
  border-radius: 10px;
  border: 1px solid #d7e0ea;
  background: #f6f9fc;
}

.bubble th,
.bubble td {
  border: 1px solid #d4dce5;
  padding: 6px 8px;
  text-align: left;
  font-size: 13px;
}

.bubble th {
  background: #edf3fa;
  font-weight: 700;
}

.thinking-live,
.thinking-details {
  margin-bottom: 8px;
  background: #f3f7fc;
  border: 1px solid #d8e2ee;
  border-radius: 10px;
  padding: 8px 10px;
}

.thinking-title {
  font-size: 12px;
  color: #4a5b70;
  font-weight: 700;
  margin-bottom: 4px;
}

.thinking-list {
  margin: 0;
  padding-left: 18px;
  color: #56677b;
  font-size: 12px;
  line-height: 1.6;
}

.thinking-trace {
  margin: 8px 0 0;
  padding: 8px;
  border: 1px dashed #cdd8e6;
  border-radius: 8px;
  background: #f8fbff;
  color: #4f6075;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.thinking-details summary {
  cursor: pointer;
  font-size: 12px;
  color: #4f5f74;
  margin-bottom: 6px;
}

.answer-body {
  min-height: 20px;
}

.msg-meta {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--sub);
}

.composer {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px calc(env(safe-area-inset-bottom) + 8px);
  background: #f7f9fb;
  border-top: 1px solid var(--line);
}

.composer__input,
.text-input,
textarea.text-input {
  border: 1px solid #c9d2dd;
  border-radius: 10px;
  background: #fff;
  padding: 9px 10px;
  font-size: 14px;
  width: 100%;
}

.composer__input {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 132px;
}

.composer__input:focus,
.text-input:focus {
  outline: none;
  border-color: #5ea9ff;
}

.send-btn,
.primary-btn,
.icon-btn {
  border: none;
  border-radius: 10px;
  background: var(--wechat-green);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 12px;
}

.icon-btn {
  min-width: 42px;
  padding: 10px;
}

.icon-btn--active {
  background: #d34334;
}

.ghost-btn {
  border: 1px solid rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 10px;
  padding: 6px 10px;
}

.ghost-btn--dark {
  border-color: #ccd5e0;
  color: var(--text);
  background: #fff;
}

button:disabled {
  opacity: 0.6;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 24, 28, 0.38);
  padding: 16px;
}

.modal--show {
  display: flex;
}

.modal__panel {
  width: min(92vw, 360px);
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.2);
}

.modal__panel--large {
  width: min(96vw, 760px);
  max-height: 88vh;
  overflow-y: auto;
}

.modal__title {
  margin: 0 0 12px;
  font-size: 18px;
}

.field-label {
  display: block;
  margin: 8px 0 5px;
  font-size: 13px;
  color: var(--sub);
}

.error-text {
  color: var(--danger);
  min-height: 18px;
  font-size: 12px;
}

.modal__actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
}

.drawer {
  position: fixed;
  right: 0;
  top: 0;
  z-index: 40;
  width: min(96vw, 960px);
  height: 100dvh;
  background: #f8fbff;
  border-left: 1px solid #d6deea;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.16);
  transform: translateX(102%);
  transition: transform 180ms ease;
  padding: calc(env(safe-area-inset-top) + 10px) 10px calc(env(safe-area-inset-bottom) + 10px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer--show {
  transform: translateX(0);
}

.drawer__header,
.drawer__toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.drawer__title {
  font-size: 18px;
  font-weight: 700;
  margin-right: auto;
}

.admin-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  padding: 10px;
}

.summary-item {
  background: #fff;
  border: 1px solid #d4deea;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 13px;
}

.admin-panel {
  flex: 1;
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.table-wrap {
  border: 1px solid #d6deea;
  border-radius: 10px;
  background: #fff;
  overflow: auto;
  flex: 1;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.records-table th,
.records-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 8px;
  font-size: 13px;
  text-align: left;
  vertical-align: top;
}

.records-table thead th {
  position: sticky;
  top: 0;
  background: #eef4fb;
  z-index: 1;
}

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.editor-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}

.editor-field textarea {
  min-height: 84px;
}

@media (min-width: 900px) {
  .app-shell {
    border-left: 1px solid #dbe3ec;
    border-right: 1px solid #dbe3ec;
  }
}
