/* ================= 基础 ================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Roboto, sans-serif;
}
:root {
  --chat-font: 15px;
  --brand: #c8102e;
  --brand-dark: #a00b28;
  --brand-soft: #fff7f0;
  --line: #f0e7dc;
  --text: #333;
  --muted: #777;
}
body {
  background: #f5f5f5;
  display: flex;
  height: 100vh;
  overflow: hidden;
  color: var(--text);
}
img {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  pointer-events: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ================= 屏幕控制 ================= */
.screen {
  display: none;
  width: 100%;
  height: 100%;
}
.screen.active {
  display: block;
  overflow-y: auto;
  background: linear-gradient(160deg, #fdf6f0 0%, #f7f5f5 60%, #f5f5f5 100%);
}

/* ================= 顶部 header ================= */
.header {
  background: linear-gradient(90deg, #c8102e 0%, #e85d04 50%, #ffba08 100%);
  padding: 18px 24px;
  color: #fff;
  position: relative;
}
.header-top {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  min-height: 46px;
}
.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}
.title-text h1 {
  font-size: 22px;
}
.top-links {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 24px;
  font-size: 14px;
  cursor: pointer;
}
.top-links span:hover {
  text-decoration: underline;
}
.emblem {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: transparent;
}
.emblem img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ================= 实验布局 ================= */
.experiment-layout {
  display: flex;
  width: 100%;
  height: calc(100vh - 72px);
  overflow: hidden;
  position: relative;
}
.main-container {
  flex: 1;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.container {
  width: 100%;
  height: 100%;
  background: #fff;
  display: flex;
  flex-direction: column;
}

/* ================= 左侧实验面板 ================= */
.experiment-panel {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 280px;
  background: #fff;
  border-right: 1px solid #e5e0d5;
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 55;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.08);
  transform: translateX(-100%);
  transition: transform 0.35s ease;
}
.experiment-panel.open {
  transform: translateX(0);
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.panel-title {
  font-size: 16px;
  font-weight: bold;
  color: var(--brand);
}
.collapse-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f8f5f0;
  border: 1px solid #e5e0d5;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--brand);
  font-size: 18px;
}
.collapse-btn:hover {
  background: var(--brand-soft);
}
.control-item {
  margin-bottom: 18px;
}
.control-item label {
  display: block;
  font-size: 14px;
  color: #333;
  margin-bottom: 8px;
}
.control-item input[type="text"] {
  width: 100%;
  padding: 10px;
  border: 1px solid #e2dbcf;
  border-radius: 6px;
  background: #faf7f2;
  font-size: 13px;
  color: #333;
}
.event-log {
  margin-top: 20px;
  background: #fef9f0;
  border-radius: 10px;
  padding: 10px;
  font-size: 11px;
  border: 1px solid #f0e2cf;
}
.log-title {
  font-weight: bold;
  margin-bottom: 8px;
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.log-list {
  max-height: 260px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 10px;
  color: #2c3e4e;
}
.log-item {
  border-bottom: 1px dotted #efdbc4;
  padding: 4px 0;
}

/* ================= 聊天区 ================= */
.main-chat-area {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 20px 24px 16px;
  overflow: hidden;
  min-height: 0;
}
.chat-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.chat-header h2 {
  font-size: 18px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 14px;
  color: var(--brand);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding-right: 6px;
}
.chat-messages::-webkit-scrollbar {
  width: 8px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: #e0c5c8;
  border-radius: 4px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--brand);
}
.message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.message.user {
  flex-direction: row-reverse;
}
.msg-avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  background: #f0f0f0;
}
.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.bubble {
  max-width: 82%;
  background: #f5f0e6;
  padding: 12px 18px;
  border-radius: 18px;
  line-height: 1.7;
  font-size: var(--chat-font);
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.user {
  background: #e8e8e8;
  color: #333;
}
.bubble.typing::after {
  content: "▌";
  color: var(--brand);
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink {
  to { visibility: hidden; }
}

/* ================= 输入区（只读展示） ================= */
.input-area {
  border: 1px solid #e2dbcf;
  border-radius: 18px;
  padding: 12px 14px;
  background: #fff;
  margin-top: 12px;
  flex-shrink: 0;
}
.input-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid #ddd;
  border-radius: 30px;
  padding: 8px 15px;
}
.input-wrapper input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  color: #333;
}
.send-btn {
  margin-top: 10px;
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 8px 24px;
  border-radius: 32px;
  cursor: pointer;
  float: right;
  font-size: 14px;
}
.send-btn:hover {
  background: var(--brand-dark);
}

/* ================= 来源序号 / 静态标记 ================= */
.ref-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  background: var(--brand);
  color: #fff;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  margin: 0 2px;
  vertical-align: middle;
  cursor: pointer;
  transition: 0.15s;
}
.ref-number:hover {
  background: var(--brand-dark);
  transform: scale(1.06);
}
.ref-static {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 3px;
  background: #e6e6e6;
  color: #888;
  border-radius: 10px;
  font-size: 11px;
  margin: 0 2px;
  vertical-align: middle;
  pointer-events: none;
}

/* ================= 侧栏（B 组） ================= */
.source-sidebar {
  display: none;
  width: 320px;
  flex-shrink: 0;
  background: #fbf7f1;
  border-left: 2px solid var(--line);
  padding: 18px;
  overflow-y: auto;
  font-size: 13px;
  color: #333;
}
.source-sidebar.show {
  display: block;
}
.source-sidebar::-webkit-scrollbar {
  width: 6px;
}
.source-sidebar::-webkit-scrollbar-thumb {
  background: #d8b5b9;
  border-radius: 3px;
}
.sidebar-title {
  font-weight: 700;
  color: var(--brand);
  font-size: 15px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
}
.source-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  transition: 0.15s;
}
.source-item:hover {
  border-color: var(--brand);
  box-shadow: 0 2px 8px rgba(200, 16, 46, 0.08);
}
.source-head {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-bottom: 6px;
}
.ref-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  background: var(--brand);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.source-name {
  font-weight: 600;
  color: #222;
  line-height: 1.4;
}
.source-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.source-summary {
  font-size: 12px;
  color: #444;
  margin-top: 6px;
  line-height: 1.6;
  background: var(--brand-soft);
  padding: 6px 8px;
  border-radius: 6px;
}
.source-link {
  margin-top: 6px;
}
.source-link a {
  font-size: 12px;
  color: var(--brand);
  text-decoration: none;
}
.source-link a:hover {
  text-decoration: underline;
}

/* ================= Tooltip（A 组） ================= */
.custom-tooltip {
  position: fixed;
  display: none;
  width: 320px;
  max-width: calc(100vw - 40px);
  background: #fff;
  border: 2px solid var(--brand);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  font-size: 12px;
  color: #333;
}
.tooltip-title {
  font-weight: 700;
  color: var(--brand);
  font-size: 14px;
  margin-bottom: 6px;
  text-align: center;
}
.tooltip-url {
  font-size: 11px;
  color: #666;
  line-height: 1.6;
  word-break: break-all;
  background: #f7f2ea;
  padding: 6px 8px;
  border-radius: 6px;
}
.tooltip-url a {
  color: var(--brand);
}
.tooltip-desc {
  margin-top: 6px;
  font-size: 12px;
  color: #444;
  line-height: 1.6;
  background: var(--brand-soft);
  padding: 6px 8px;
  border-radius: 6px;
}

/* ================= 底部按钮栏 ================= */
.experiment-bottom {
  display: flex;
  height: 72px;
  background: #fff;
  border-top: 1px solid var(--line);
  position: relative;
  z-index: 10;
}
.experiment-bottom .bottom-half {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
}
.experiment-bottom .bottom-half.left {
  border-right: 1px solid var(--line);
}
.bottom-half .btn-secondary,
.bottom-half .btn-primary {
  padding: 12px 32px;
  font-size: 15px;
  font-weight: 500;
  border-radius: 26px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}
.bottom-half .btn-secondary {
  background: #f5f5f5;
  color: #555;
  border: 1px solid #ddd;
}
.bottom-half .btn-secondary:hover {
  background: #ececec;
  color: #333;
  transform: translateY(-1px);
}
.bottom-half .btn-primary {
  background: linear-gradient(90deg, #c8102e, #e85d04);
  color: #fff;
  box-shadow: 0 4px 14px rgba(200, 16, 46, 0.3);
}
.bottom-half .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(200, 16, 46, 0.4);
}

/* ================= 问卷 / 复述 / 致谢 ================= */
.survey-wrap {
  max-width: 860px;
  width: calc(100% - 80px);
  margin: 48px auto;
  padding: 36px 44px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(200, 16, 46, 0.08);
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  position: relative;
}
.survey-wrap-wide {
  max-width: 1180px;
}
.survey-wrap::-webkit-scrollbar {
  width: 8px;
}
.survey-wrap::-webkit-scrollbar-thumb {
  background: #e0c5c8;
  border-radius: 4px;
}
.survey-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--brand);
}
.brand-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--line);
}
.brand-logo {
  width: 40px;
  height: 40px;
}
.brand-bar h1 {
  font-size: 20px;
  color: var(--brand);
  font-weight: bold;
}
.survey-wrap h2 {
  color: var(--brand);
  font-size: 22px;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--line);
}
.survey-wrap h3 {
  margin: 28px 0 12px;
  font-size: 16px;
  color: #333;
  border-left: 4px solid var(--brand);
  padding-left: 10px;
}
.survey-hint {
  font-size: 13px;
  color: #888;
  margin-bottom: 22px;
  line-height: 1.6;
}
.survey-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: start;
}
.survey-col {
  min-width: 0;
}
.survey-item {
  margin-bottom: 20px;
}
.survey-item p {
  font-size: 14px;
  color: #333;
  margin-bottom: 8px;
  line-height: 1.6;
}
.survey-wrap select,
.survey-wrap input[type="text"] {
  width: 100%;
  max-width: 420px;
  padding: 10px 12px;
  border: 1px solid #e2dbcf;
  border-radius: 8px;
  font-size: 14px;
  background: #fefcf8;
  transition: border 0.2s, box-shadow 0.2s;
}
.survey-wrap select:focus,
.survey-wrap input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
}

/* ================= 李克特 1-7 ================= */
.likert {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.likert label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 36px;
  padding: 0 6px;
  font-size: 13px;
  border: 1px solid #e2dbcf;
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
  color: #555;
  transition: 0.15s;
}
.likert label:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}
.likert input {
  display: none;
}
.likert label:has(input:checked) {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: 0 2px 8px rgba(200, 16, 46, 0.25);
}

/* ================= 任务说明 ================= */
.task-box {
  background: #fefcf8;
  border-left: 4px solid var(--brand);
  padding: 22px 26px;
  border-radius: 10px;
  line-height: 1.9;
  font-size: 15px;
  color: #444;
}
.task-main {
  margin-bottom: 12px;
}
.consent-text {
  font-size: 14px;
  line-height: 1.9;
  color: #444;
  background: #fefcf8;
  padding: 20px;
  border-radius: 10px;
  border-left: 4px solid var(--brand);
}
.consent-text p {
  margin-bottom: 10px;
}
.consent-check {
  display: block;
  margin: 22px 0;
  font-size: 14px;
  color: #333;
}

/* ================= 通用按钮 ================= */
.nav-btns {
  margin-top: 30px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}
.nav-btns button {
  padding: 11px 26px;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
.btn-primary {
  background: linear-gradient(90deg, #c8102e, #e85d04);
  color: #fff;
  box-shadow: 0 4px 12px rgba(200, 16, 46, 0.25);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(200, 16, 46, 0.35);
}
.btn-secondary {
  background: #f5f5f5;
  color: #555;
}
.btn-secondary:hover {
  background: #eee;
}

/* ================= 文本域（最终开放题） ================= */
.recall-textarea {
  width: 100%;
  min-height: 120px;
  padding: 14px;
  border: 1px solid #e2dbcf;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.7;
  resize: vertical;
  font-family: inherit;
  background: #fefcf8;
}
.recall-textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
}

/* ================= 致谢 ================= */
.done-wrap {
  text-align: center;
  padding: 60px 36px;
}
.done-wrap h2 {
  border: none;
  padding: 0;
  font-size: 24px;
  margin-bottom: 24px;
}
.done-text {
  font-size: 14px;
  color: #666;
  margin-bottom: 12px;
  line-height: 1.8;
}

/* ================= 响应式 ================= */
@media screen and (max-width: 1024px) {
  .source-sidebar {
    width: 280px;
  }
}
@media screen and (max-width: 900px) {
  .survey-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .survey-wrap,
  .survey-wrap-wide {
    width: calc(100% - 32px);
    margin: 20px auto;
    padding: 24px;
    max-height: none;
  }
  .survey-wrap h2 {
    font-size: 18px;
  }
  .likert label {
    min-width: 34px;
    height: 32px;
    font-size: 12px;
  }
  .nav-btns {
    flex-direction: column-reverse;
  }
  .nav-btns button {
    width: 100%;
  }
}
@media screen and (max-width: 768px) {
  body {
    overflow: auto;
    height: auto;
    min-height: 100vh;
    display: block;
  }
  .screen {
    height: auto;
    min-height: 100vh;
  }
  .screen.active {
    overflow-y: auto;
  }
  .experiment-layout {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .main-chat-area {
    flex-direction: column;
    padding: 12px;
    gap: 12px;
    overflow: visible;
  }
  .chat-messages {
    max-height: 55vh;
    min-height: 220px;
  }
  .bubble {
    max-width: 92%;
    font-size: 14px;
  }
  .source-sidebar {
    width: 100%;
    max-height: 60vh;
    border-left: none;
    border-top: 2px solid var(--line);
    padding: 14px;
  }
  .experiment-bottom {
    flex-direction: column;
    height: auto;
  }
  .experiment-bottom .bottom-half {
    padding: 10px 12px;
  }
  .experiment-bottom .bottom-half.left {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .bottom-half .btn-secondary,
  .bottom-half .btn-primary {
    width: 100%;
    padding: 10px 20px;
    font-size: 14px;
  }
  .custom-tooltip {
    width: 280px;
  }
  .header {
    padding: 14px 12px;
  }
  .header-top {
    flex-direction: column;
    gap: 6px;
  }
  .title-text h1 {
    font-size: 16px;
  }
  .top-links {
    position: static;
    transform: none;
    justify-content: center;
    margin-top: 2px;
  }
}
@media screen and (max-width: 480px) {
  .title-text h1 {
    font-size: 15px;
  }
  .bubble {
    max-width: 95%;
    padding: 8px 12px;
  }
  .msg-avatar {
    width: 30px;
    height: 30px;
  }
  .ref-number,
  .ref-static {
    min-width: 18px;
    height: 18px;
    font-size: 10px;
  }
}