:root {
  --paper: #f1f8f4;
  --paper-deep: #e3f0ea;
  --sheet: #fffdf7;
  --sheet-line: #d8e3dd;
  --ink: #20342f;
  --ink-deep: #172923;
  --muted: #687b74;
  --folder: #243b35;
  --folder-soft: #315349;
  --mint: #d8f3ea;
  --rose: #8f4a55;
  --rose-soft: #f3dedc;
  --gold: #b17732;
  --green: #24765a;
  --red: #b94b4b;
  --shadow: 0 22px 58px rgba(36, 59, 53, 0.15);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 8%, rgba(216, 243, 234, 0.95), transparent 28%),
    linear-gradient(135deg, #f7fbf8 0%, var(--paper) 48%, #edf7f3 100%);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(143, 74, 85, 0.28);
  outline-offset: 2px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  background:
    repeating-linear-gradient(#fffdf7, #fffdf7 34px, rgba(216, 227, 221, 0.72) 35px),
    var(--sheet);
  border: 1px solid var(--sheet-line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 30px;
  position: relative;
}

.login-card::before {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  top: 0;
  height: 5px;
  background: var(--rose);
  border-radius: 0 0 6px 6px;
}

.admin-login-page {
  background:
    radial-gradient(circle at 80% 12%, rgba(143, 74, 85, 0.16), transparent 28%),
    linear-gradient(135deg, #f7fbf9, #e8f5ef);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--folder);
  color: #f7fff9;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
}

.admin-shell .brand-mark,
.admin-login-page .brand-mark {
  background: var(--rose);
}

.brand-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.05;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.sidebar .brand-subtitle {
  color: #bad8cf;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
  background: var(--folder);
  color: #e4f6ef;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 12px 0 30px rgba(36, 59, 53, 0.12);
}

.admin-shell .sidebar {
  background: #2f3630;
}

.nav {
  display: grid;
  gap: 9px;
  margin-top: 28px;
}

.nav-link {
  min-height: 42px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 12px;
  color: #c7e1d8;
  font-weight: 760;
  font-size: 14px;
  border: 1px solid transparent;
}

.nav-link.active,
.nav-link:hover {
  background: var(--mint);
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.16);
}

.user-box {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  padding: 12px;
}

.user-email {
  font-size: 13px;
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  margin-top: 4px;
  color: #bad8cf;
  font-size: 12px;
}

.main {
  min-width: 0;
  padding: 30px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 22px;
}

.page-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.04;
  margin: 0;
  letter-spacing: 0;
}

.page-kicker {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 760px;
  line-height: 1.7;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.card,
.panel {
  background: var(--sheet);
  border: 1px solid var(--sheet-line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(36, 59, 53, 0.08);
}

.agent-card {
  padding: 20px;
  display: grid;
  gap: 14px;
  min-height: 230px;
  position: relative;
  overflow: hidden;
}

.agent-card::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 0;
  height: 4px;
  border-radius: 0 0 6px 6px;
  background: var(--rose);
}

.agent-card h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
}

.agent-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.72;
}

.card-footer {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 25px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf5f1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.badge.active {
  background: var(--mint);
  color: var(--green);
}

.badge.draft {
  background: #fff2db;
  color: var(--gold);
}

.badge.disabled,
.badge.error {
  background: #f8e7e6;
  color: var(--red);
}

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 780;
  color: var(--ink);
  background: #e8f1ed;
  border: 1px solid #cdded7;
}

.btn:hover {
  filter: brightness(0.98);
}

.btn.primary {
  background: var(--folder);
  border-color: var(--folder);
  color: #f7fff9;
}

.btn.ghost {
  background: transparent;
  border-color: #cdded7;
}

.sidebar .btn.ghost {
  color: #e4f6ef;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn.danger {
  background: #f8e7e6;
  border-color: #eec4c1;
  color: var(--red);
}

.btn.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 820;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid #cdded7;
  border-radius: 8px;
  padding: 11px 12px;
  background: #fffef9;
  color: var(--ink);
  outline: none;
}

.textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.65;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(143, 74, 85, 0.14);
}

.error-line {
  color: var(--red);
  min-height: 20px;
  font-size: 13px;
}

.chat-layout {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 18px;
  height: calc(100vh - 60px);
}

.conversation-list {
  padding: 16px;
  overflow: auto;
  background: #f7fbf9;
}

.conversation-list::before {
  content: "稿件夹";
  display: block;
  margin: 0 0 12px;
  color: var(--rose);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.conversation-item {
  width: 100%;
  text-align: left;
  display: block;
  border-radius: 8px;
  padding: 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  margin-top: 8px;
  border: 1px solid transparent;
}

.conversation-item.active,
.conversation-item:hover {
  background: var(--mint);
  border-color: #bfe5d8;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--sheet);
}

.chat-header {
  padding: 20px 22px;
  border-bottom: 1px solid var(--sheet-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-title {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 25px;
}

.chat-guide {
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.6;
}

.messages {
  overflow: auto;
  padding: 24px;
  display: grid;
  align-content: start;
  gap: 16px;
  background:
    repeating-linear-gradient(#fffdf7, #fffdf7 35px, rgba(216, 227, 221, 0.68) 36px),
    var(--sheet);
}

.empty-state {
  border: 1px dashed #bdd5cc;
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.86);
  padding: 26px;
  max-width: 760px;
}

.empty-state h3 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.message {
  display: grid;
  gap: 6px;
}

.message.user {
  justify-items: end;
}

.message-role {
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.bubble {
  max-width: min(780px, 100%);
  border-radius: 8px;
  padding: 13px 15px;
  line-height: 1.78;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .bubble {
  background: var(--folder);
  color: #f7fff9;
}

.message.assistant .bubble {
  background: #eef7f3;
  border: 1px solid #cdded7;
  color: var(--ink);
}

.composer {
  padding: 16px;
  border-top: 1px solid var(--sheet-line);
  background: #f8fbf9;
}

.composer-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.composer textarea {
  min-height: 62px;
  max-height: 180px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(330px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--sheet-line);
  padding: 13px 11px;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  background: #f4faf7;
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(172px, 1fr));
  gap: 14px;
}

.stat {
  padding: 18px;
  background:
    linear-gradient(180deg, #fffdf7, #f8fbf9);
}

.stat-value {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 700;
}

.stat-label {
  color: var(--muted);
  margin-top: 5px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.muted {
  color: var(--muted);
}

.hide {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .card,
  .panel,
  .btn,
  .nav-link,
  .conversation-item {
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
  }

  .agent-card:hover,
  .panel:hover {
    transform: translateY(-1px);
  }
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    gap: 12px;
  }

  .nav {
    display: flex;
    overflow: auto;
    margin-top: 6px;
  }

  .user-box {
    display: none;
  }

  .main {
    padding: 18px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .chat-layout,
  .admin-grid {
    grid-template-columns: 1fr;
    height: auto;
  }

  .conversation-list {
    max-height: 240px;
  }

  .chat-panel {
    min-height: 72vh;
  }

  .split,
  .composer-box {
    grid-template-columns: 1fr;
  }
}
