:root {
  color-scheme: light;
  --bg: #fff7f7;
  --panel: #ffffff;
  --ink: #201314;
  --muted: #674749;
  --line: #e2b8ba;
  --soft: #fff0f1;
  --soft-2: #fbe3e4;
  --accent: #b11226;
  --accent-dark: #7f0d1b;
  --accent-2: #d13f4d;
  --danger: #9b0d1b;
  --shadow: 0 8px 24px rgba(112, 13, 27, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(180deg, #ffffff 0, #fff7f7 260px, #fffafa 100%);
  color: var(--ink);
  font-size: 16px;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 3px solid var(--accent);
}

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

.brand-kicker {
  margin: 0 0 6px !important;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.org-support {
  max-width: 820px;
  color: #44292b;
  font-size: 14px;
  line-height: 1.55;
  margin-top: 10px;
  padding-left: 12px;
  border-left: 4px 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;
  font-weight: 700;
}

button:hover, .link-button:hover { background: var(--accent-dark); }

.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;
  box-shadow: var(--shadow);
}

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

button.secondary, .link-button {
  background: var(--soft-2);
  color: var(--accent-dark);
  border: 1px solid var(--line);
}
button.secondary:hover, .link-button:hover {
  background: #f4cfd2;
}

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;
  box-shadow: var(--shadow);
}

.notice {
  padding: 14px 16px;
  line-height: 1.65;
  background: #fff;
}
.privacy {
  border-left: 5px solid var(--accent);
  background: var(--soft);
}

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

.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: #ffe7e9;
  border: 1px solid #e19ba2;
  margin-left: 12%;
  font-weight: 500;
}
.message.assistant {
  background: #ffffff;
  border: 1px solid #d8a8ad;
  margin-right: 8%;
  box-shadow: 0 1px 2px rgba(122, 13, 27, .08);
}
.message.thinking {
  color: var(--accent-dark);
  font-weight: 700;
}
.thinking-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--accent);
  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: 800;
  color: var(--accent-dark);
}
.answer-section-title {
  display: block;
  margin: 10px 0 4px;
  font-weight: 800 !important;
  color: var(--accent-dark) !important;
}
.message .sources {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 8px;
  color: var(--muted);
  font-size: 14px;
}
.risk { color: var(--danger); font-weight: 700; }

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

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

.attachment-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.attach-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  background: var(--soft-2);
  color: var(--accent-dark);
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
}
.attach-button input { display: none; }
.attachment-list {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.small {
  padding: 7px 10px;
  font-size: 13px;
}

.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: #fffdfd;
}
.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: 28px; }
  .message.user, .message.assistant { margin-left: 0; margin-right: 0; }
  .composer-actions { flex-direction: column; }
}
