:root {
  color-scheme: light;
  --bg: #eef3f2;
  --panel: #ffffff;
  --ink: #102126;
  --muted: #46565c;
  --line: #b8c7c4;
  --accent: #0b6b5d;
  --accent-2: #8a4f22;
  --danger: #9f2f32;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
}

.shell {
  width: min(1080px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

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

h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 30px; }
h2 { font-size: 18px; }
p { line-height: 1.7; }
.topbar p, .muted { color: var(--muted); margin: 8px 0 0; }

.org-support {
  max-width: 820px;
  color: #26383d;
  font-size: 14px;
  line-height: 1.55;
  margin-top: 10px;
  padding-left: 12px;
  border-left: 3px solid var(--accent);
}

.link-button, button {
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  font-size: 15px;
}

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

.auth-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto auto;
  gap: 10px;
}

button.secondary, .link-button {
  background: #e7eeec;
  color: var(--ink);
}

button:disabled { opacity: .55; cursor: not-allowed; }

.notice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.notice, .admin-section, .chat-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.notice {
  padding: 14px 16px;
  line-height: 1.65;
}
.privacy { border-left: 4px solid var(--accent-2); }

.chat-panel { overflow: hidden; }
.chat-box {
  min-height: 420px;
  max-height: 62vh;
  overflow: auto;
  padding: 18px;
  background: #f8fbfa;
}

.message {
  position: relative;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--ink);
  font-size: 16px;
}
.message.user {
  background: #dcebe7;
  border: 1px solid #9fbab3;
  margin-left: 12%;
  font-weight: 500;
}
.message.assistant {
  background: #ffffff;
  border: 1px solid #aebfbc;
  margin-right: 8%;
  box-shadow: 0 1px 2px rgba(16, 33, 38, .08);
}
.message.thinking {
  color: #40525a;
  font-weight: 600;
}
.thinking-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 4px;
  border-radius: 50%;
  background: #005f73;
  animation: thinkingPulse 1.2s infinite ease-in-out;
}
.thinking-dot:nth-child(2) { animation-delay: .15s; }
.thinking-dot:nth-child(3) { animation-delay: .3s; }

@keyframes thinkingPulse {
  0%, 80%, 100% { opacity: .35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}
.message.assistant strong {
  font-weight: 700;
  color: #08191d;
}
.answer-section-title {
  display: block;
  margin: 10px 0 4px;
  font-weight: 800 !important;
  color: #061d22 !important;
}
.message .sources {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 8px;
  color: #33444a;
  font-size: 14px;
}
.risk { color: var(--danger); font-weight: 600; }

.composer {
  border-top: 1px solid var(--line);
  padding: 14px;
  background: #fbfcfc;
}

textarea, input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
textarea { resize: vertical; }
.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}
.admin-section {
  padding: 16px;
  margin-bottom: 14px;
}
.admin-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.hidden { display: none; }
.list, .log-list { display: grid; gap: 8px; margin-top: 12px; }
.item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfc;
}
.item-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.check-row input { width: auto; }

@media (max-width: 760px) {
  .topbar, .section-title { flex-direction: column; align-items: stretch; }
  .notice-grid, .admin-grid { grid-template-columns: 1fr; }
  .top-actions, .auth-form { display: grid; grid-template-columns: 1fr; }
  h1 { font-size: 24px; }
  .message.user, .message.assistant { margin-left: 0; margin-right: 0; }
  .composer-actions { flex-direction: column; }
}
