/* style.css */
/* 📦 颜色变量系统（放在最顶部） */
:root {
  --font-default: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg-dark: #0b0f1a;
  --bg-card: #161d2f;
  --bg-input: #1e293b;
  --bg-btn: #2a3b66;
  --bg-btn-hover: #3b4f8a;
  --bg-btn-action: #5c6bc0;
  --bg-btn-action-hover: #6b7ac9;
  --color-text: #e6e6e6;
  --color-text-light: #999;
  --color-gold: #f8c850;
  --color-gold-light: #f8d49d;
}

/* 🔥 全局统一：干净 Firefox 风格滚动条（全平台一致） */
* {
  scrollbar-width: thin;
  scrollbar-color: #3b4f8a #161d2f;
}
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
*::-webkit-scrollbar-track {
  background: #161d2f;
  border-radius: 3px;
}
*::-webkit-scrollbar-thumb {
  background-color: #3b4f8a;
  border-radius: 3px;
  border: none;
}

/* 基础重置与全局样式 */
* {
  box-sizing: border-box;
  font-family: inherit;
  margin: 0;
  padding: 0;
}
html {
  font-family: var(--font-default);
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}
body {
  background: var(--bg-dark);
  color: var(--color-text);
  line-height: 1.5;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  /* ✅ 新增：平滑滚动 */
  scroll-behavior: smooth;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
button,
input,
select,
textarea {
  font: inherit;
}
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}
/* 屏幕切换核心样式 */
.screen {
  display: none !important;
  min-width: 0;
  max-width: 100%;
}
.screen.active {
  display: block !important;
}
/* 标签页内部内容 */
.tab-screen {
  display: none !important;
}
.tab-screen.active {
  display: block !important;
}
/* 文字样式 */
h1, h2 {
  color: var(--color-gold);
  margin-bottom: 16px;
}
h3 {
  color: var(--color-text);
  margin-bottom: 12px;
}
/* 按钮样式 */
.btn {
  background: var(--bg-btn);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  margin: 6px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  flex: 1;
  min-width: 100px;
}
.btn:hover {
  background: var(--bg-btn-hover);
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(1px);
}
/* ✅ FIX #6：补齐所有按钮的 :active 状态 */
.btn.primary { background: #732b2b; }
.btn.primary:hover { background: #8a3434; }
.btn.primary:active { transform: translateY(1px); }
.btn.warn { background: #2b5a2b; }
.btn.warn:hover { background: #366e36; }
.btn.warn:active { transform: translateY(1px); }
.btn.success { background: #2a7a3e; }
.btn.success:hover { background: #329149; }
.btn.success:active { transform: translateY(1px); }
.btn.hat { background: #7d5a30; }
.btn.hat:hover { background: #946c40; }
.btn.hat:active { transform: translateY(1px); }
.btn.tab-btn.active {
  background: #ffd700 !important;
  color: #000 !important;
  font-weight: bold;
}
.btn:disabled {
  background: #444 !important;
  color: #888;
  cursor: not-allowed;
  opacity: 0.7;
  transform: none !important;
}

/* ==================== ✅ 创建界面专用样式 ==================== */

/* 角色创建标题居中 */
#screen-create h1 {
  text-align: center;
  margin-top: 10px;
}

/* 分隔线 */
#screen-create hr,
#screen-main hr {
  border: none;
  height: 2px;
  background: linear-gradient(90deg, #4a5588, #8a94c2, #4a5588);
  margin: 14px 0;
  border-radius: 2px;
}

/* 创建界面标题行 */
.create-header-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
  padding: 0 20px;
  position: relative;
}
.create-header-row h2 {
  margin: 0;
}

/* 音乐按钮 */
.music-btn {
  position: absolute;
  left: 0;
  background: #161d2f;
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.music-btn-main {
  position: absolute;
  left: 0;
  background: #161d2f;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #4a5588;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
  user-select: none;
}

/* 快速测试按钮 */
.quick-test-btn {
  position: absolute;
  right: 0;
  background: #161d2f;
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

/* 主界面顶部右侧便签按钮 */
.note-btn-main {
  position: absolute;
  right: 0;
  background: #161d2f;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #4a5588;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
  user-select: none;
}

/* 主界面顶部行 */
.main-header-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  min-width: 0;
  overflow: hidden;
}
.main-header-row h1 {
  max-width: 100%;
  min-width: 0;
  text-align: center;
  overflow-wrap: anywhere;
}

/* 进入霍格沃茨按钮卡片 */
.enter-card {
  text-align: center;
  background: transparent;
  padding: 0;
}
.enter-btn {
  min-height: 80px;
  font-size: 18px;
  width: 100%;
  margin: 0 !important;
  box-sizing: border-box;
}

/* 随机名字按钮 */
.random-name-btn {
  background: #473c66;
  width: 100%;
}

/* 分院帽按钮 */
.sorting-hat-btn {
  width: 100%;
}

/* 魔杖按钮组 */
.wand-btn-row {
  display: flex;
  gap: 0;
}
.wand-draw-btn {
  background: #3c5a66;
  flex: 1;
}
.wand-try-btn {
  flex: 1;
}

/* ==================== 标签栏 ==================== */
.tab {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.tab-btn {
  flex: 1;
  min-width: 0;
  background: #2d3756;
  border: none;
  color: #fff;
  padding: 7px 4px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}
.tab-btn:hover {
  background: #3b4f8a;
}
.tab-btn.active {
  background: #4a5588;
  font-weight: bold;
}

/* ====================== ✅ 行动日志 / 日志区域 ====================== */
.log {
  background: var(--bg-dark);
  border-radius: 8px;
  padding: 10px;
  height: 80px;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 8px 0;
  width: 100%;
  font-size: 12px;
}
.log p {
  margin: 4px 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.log .me { color: #9999cc; }
.log .npc { color: #8a8a6a; opacity: 0.75; }
.log .log-story { color: rgba(255,255,255,0.7); }
.log .sys { color: #aaa; }
.log .good { color: #8f8; }
.log .bad { color: #f66; }
.log .legend { color: #fc0; font-weight: bold; }

.log-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.log-title-text {
  flex: 0 0 auto;
  min-width: 0;
}

.log-filters {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px 8px;
  min-width: 0;
  max-width: 100%;
}

.log-filter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}

.log-filter input {
  width: auto;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
}

.log-filter-story span {
  color: rgba(255,255,255,0.7);
}

.log-filter-npc span {
  background: linear-gradient(to right,#dc143c,#ffd700,#4169e1,#5cb85c);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.log-filter-player span {
  color: #9999cc;
}

/* 输入框 */
input {
  width: 100%;
  padding: 10px 14px;
  margin: 8px 0;
  border-radius: 8px;
  border: none;
  background: var(--bg-input);
  color: #fff;
  font-size: 16px;
}
input::placeholder {
  color: var(--color-text-light) !important;
}
.chat-input-group {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.chat-input-group input {
  margin: 0;
  flex: 1;
}
.chat-input-group .btn {
  margin: 0;
  min-width: 80px;
  flex: none;
}

/* 下拉框 */
select {
  width: 100%;
  padding: 10px 14px;
  margin: 8px 0;
  border-radius: 8px;
  border: none;
  background: var(--bg-input);
  color: var(--color-text-light);
  font-size: 16px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 36px;
}
select option {
  color: #fff;
  background: var(--bg-input);
}
select:valid {
  color: #ffffff !important;
}

/* 状态标签 */
.stat {
  display: inline-block;
  background: var(--bg-input);
  padding: 6px 10px;
  border-radius: 6px;
  margin: 4px;
}

/* 卡片 */
.card {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 14px;
  margin: 10px 0;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* 随机按钮行 */
.random-row {
  display: flex;
  gap: 8px;
  margin: 8px 0;
  flex-wrap: wrap;
}

/* 分院帽/魔杖结果面板 */
#wand-result,
#sorting-result {
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  display: none;
  line-height: 1.5;
}
#wand-result.gryff,
#sorting-result.gryff { background: #732b2b; color: white !important; }
#wand-result.slyth,
#sorting-result.slyth { background: #2b5a2b; color: white !important; }
#wand-result.raven,
#sorting-result.raven { background: #2a4b7a; color: white !important; }
#wand-result.huff,
#sorting-result.huff { background: #b99f55; color: black !important; }
#wand-result.good,
#sorting-result.good { background: #1a3a23; color: #8f8 !important; }
#wand-result.bad,
#sorting-result.bad { background: #3a1a1a; color: #f66 !important; }
#wand-result.legend,
#sorting-result.legend { background: #4a3a1a; color: #fc0 !important; }

/* 七彩渐变动画 */
.rainbow-legend {
  position: relative;
  color: #ffffff;
  font-weight: bold;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
  border-radius: 8px;
  display: block;
  padding: 14px;
  margin-top: 10px;
  z-index: 1;
  will-change: background-position;
}
.rainbow-legend::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  border-radius: 8px;
  background: linear-gradient(90deg, #ff0000, #ff9800, #ffff00, #00ff00, #0098ff, #0000ff, #ff00ff, #ff0000);
  background-size: 1400% 100%;
  opacity: 0.4;
  animation: rainbowFlow 8s linear infinite;
}

@keyframes rainbowFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

/* 个人信息折叠按钮 */
.info-collapse-btn {
  background: var(--bg-btn-action);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.2s;
}
.info-collapse-btn:hover {
  background: var(--bg-btn-action-hover);
  transform: translateY(-1px);
}

/* 个人信息文字颜色 */
.info-label { color: var(--color-gold-light); }
.info-value { color: #c9d1d9; }

/* 行动按钮 */
.action-btn {
  width: 100%;
  padding: 12px;
  margin: 6px 0;
  border: none;
  border-radius: 6px;
  background: var(--bg-btn-action);
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.action-btn:hover {
  background: var(--bg-btn-action-hover);
  transform: translateY(-1px);
}
.action-btn:active {
  transform: translateY(1px);
}
.action-btn:disabled {
  background: #444 !important;
  cursor: not-allowed;
}

/* 卡片内部标题/信息 */
.title {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 10px;
  color: var(--color-gold);
}
.info {
  font-size: 16px;
  margin: 8px 0;
}

/* ==================== 行动面板网格 ==================== */
.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.action-grid .action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  margin: 0;
  line-height: 1.25;
}

.action-grid .action-btn:last-child {
  grid-column: 1 / -1;
}

/* ==================== 探索区域 ==================== */
.explore-container {
  max-height: 400px;
  overflow: auto;
  margin-top: 8px;
}
.back-btn {
  margin-top: 10px;
}

/* ==================== 时间线 ==================== */
.timeline {
  margin: 12px 0;
  line-height: 1.7;
}
.timeline h4 {
  margin: 8px 0 4px;
  font-size: 15px;
  color: var(--color-gold);
}
.timeline p {
  margin: 3px 0;
  font-size: 14px;
  color: var(--color-text);
}
.event-date {
  display: inline-block;
  width: 130px;
  font-weight: bold;
  color: var(--bg-btn-action);
}
.divider {
  height: 1px;
  background: #2a3b66;
  margin: 12px 0;
}

/* ==================== 时间轴剧情卡片 ==================== */
.tl-story-entry {
  margin: 4px 0;
  background: #1a2438;
  border: 1px solid #2a3656;
  border-radius: 8px;
  font-size: 13px;
  overflow: hidden;
}
.tl-story-completed {
  border-color: #1e3a1e;
}
.tl-story-available {
  border-color: #4a3580;
}
.tl-story-expired {
  border-color: #5a3040;
  opacity: 0.78;
}
.tl-story-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
}
.tl-story-toggle {
  flex: 1;
  color: #e0e0e0;
  cursor: pointer;
  font-weight: 500;
  transition: color 0.15s;
}
.tl-story-toggle:hover {
  color: #f8c850;
}
.tl-toggle-arrow {
  color: #8899aa;
  font-size: 11px;
}
.tl-story-available .tl-story-toggle {
  color: #c4a5ff;
}
.tl-story-available .tl-story-toggle:hover {
  color: #d8b8ff;
}
.tl-story-badge {
  font-size: 12px;
  font-weight: bold;
}
.tl-badge-done {
  color: #4caf50;
}
.tl-badge-active {
  color: #d8b8ff;
  background: rgba(106,79,176,0.25);
  border-radius: 6px;
  padding: 2px 7px;
}
.tl-badge-expired {
  color: #ff9aa8;
  background: rgba(190,48,72,0.16);
  border-radius: 6px;
  padding: 2px 7px;
}
.tl-story-detail {
  padding: 4px 12px 10px;
  border-top: 1px solid #2a3656;
  background: rgba(0,0,0,0.15);
}
.tl-story-detail p {
  margin: 4px 0;
  font-size: 12px;
  color: #bbb;
  line-height: 1.6;
}
.story-trigger-btn {
  background: #4a3580;
  border: none;
  color: #fff;
  padding: 4px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
}
.story-trigger-btn:hover {
  background: #6a4fb0;
}

/* ==================== 剧情模态框 ==================== */
.story-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: story-fade-in 0.3s ease;
}
@keyframes story-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.story-dialog {
  background: linear-gradient(135deg, #0c1525 0%, #1a1a3e 100%);
  border: 1px solid #3a3a6e;
  border-radius: 16px;
  padding: 24px;
  max-width: 520px;
  width: 90%;
  box-shadow: 0 0 60px rgba(100, 80, 200, 0.3);
  animation: story-slide-up 0.3s ease;
}
@keyframes story-slide-up {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.story-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.story-chapter {
  background: #2d1f5e;
  color: #c4a5ff;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}
.story-title {
  flex: 1;
  color: #f8d49d;
  font-size: 16px;
  font-weight: 700;
}
.story-progress {
  color: #667;
  font-size: 12px;
}
.story-progress-bar {
  height: 3px;
  background: #1a1a3e;
  border-radius: 2px;
  margin-bottom: 16px;
  overflow: hidden;
}
.story-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6a4fb0, #c4a5ff);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.story-content {
  margin-bottom: 20px;
}
.story-speaker {
  color: #c4a5ff;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}
.story-text {
  color: #ddd;
  font-size: 15px;
  line-height: 1.9;
  min-height: 60px;
  overflow-wrap: anywhere;
}
.story-text-block {
  margin: 0 0 14px;
}
.story-text-block:last-child {
  margin-bottom: 0;
}
.story-narration-block {
  color: #d8dbe6;
}
.story-observation-list {
  display: grid;
  gap: 8px;
  margin: 2px 0 16px;
  padding: 10px 12px;
  list-style: none;
  color: #d8dbe6;
  border-left: 3px solid #f8c850;
  background: rgba(18, 25, 42, 0.7);
  border-radius: 0 6px 6px 0;
}
.story-observation-list li {
  position: relative;
  padding-left: 16px;
}
.story-observation-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.78em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f8c850;
}
.story-dialogue-block {
  color: #f2f2f2;
  margin-top: 16px;
}
.story-inline-speaker {
  color: #c4a5ff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 6px;
}
.story-dialogue-line {
  margin: 0;
  padding-left: 1em;
  color: #f0f1f6;
  font-weight: 600;
}
.story-dialogue {
  color: #f8d49d;
  font-style: normal;
  font-weight: 700;
}
.story-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.story-choice-btn {
  background: #1a2438;
  border: 1px solid #3a3a6e;
  color: #e0e0e0;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: all 0.2s;
}
.story-choice-btn:hover {
  background: #2a3460;
  border-color: #6a4fb0;
  color: #fff;
}
.story-next-btn {
  text-align: center;
  background: #2d1f5e;
  border-color: #4a3580;
}
.story-next-btn:hover {
  background: #4a3580;
}

/* ==================== ✅ 存档系统 ==================== */
#saveBox {
  margin-top: 12px;
  display: none;
  background: var(--bg-dark);
  border-radius: 8px;
  padding: 14px;
  border: 1px solid var(--bg-input);
}
#saveBox.show {
  display: block !important;
}
.save-btn-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  width: 100%;
}
.save-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.save-btn.save {
  background: #37594e;
  color: #fff;
}
.save-btn.save:hover {
  background: #467062;
  transform: translateY(-1px);
}
.save-btn.load {
  background: #3a5270;
  color: #fff;
}
.save-btn.load:hover {
  background: #46648a;
  transform: translateY(-1px);
}
.save-btn.reset {
  background: #6b3f48;
  color: #fff;
}
.save-btn.reset:hover {
  background: #854b56;
  transform: translateY(-1px);
}
/* ✅ 统一激活状态 */
.save-btn.active {
  font-weight: bold;
  border: 2px solid #fff;
  opacity: 1 !important;
}
.save-btn.save.active {
  background: #467062 !important;
}
.save-btn.load.active {
  background: #46648a !important;
}
.save-modal {
  overflow: visible;
}

/* 存档列表 */
#slotBox,
#slotBox-create {
  max-height: 500px;
  overflow-y: auto;
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* 存档卡片 */
.slot-btn {
  background: var(--bg-card);
  border: 1px solid #2a3b66;
  color: var(--color-text);
  padding: 12px 8px;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  font-size: 14px;
  transition: all 0.2s ease;
}
.slot-btn:hover {
  background: #242f47;
  border-color: #3b4f8a;
  transform: translateY(-1px);
}
.slot-desc {
  font-size: 12px;
  color: #a0aec0;
  margin-top: 4px;
}
.slot-btn.empty {
  background: var(--bg-card) !important;
  border-color: #2a3b66 !important;
  color: #aaa !important;
}
.slot-btn.empty:hover {
  transform: none;
  background: var(--bg-input);
  border-color: #2a3b66;
}

/* 存档卡片行 */
.save-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==================== 背包系统 ==================== */
.bag-tab-row {
  display: flex;
  gap: 6px;
  margin: 10px 0;
  flex-wrap: wrap;
}
.bag-tab {
  background: var(--bg-btn);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}
.bag-tab:hover {
  background: var(--bg-btn-hover);
}
.bag-tab.active {
  background: var(--bg-btn-action);
}

/* ====================== 背包格子核心设置 ====================== */
.bag-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.bag-slot {
  aspect-ratio: 1/1;
  min-height: 48px;
  background: var(--bg-input);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #aaa;
  text-align: center;
  padding: 3px;
  word-break: break-word;
  white-space: normal;
  overflow: hidden;
  line-height: 1.1;
  max-width: 100%;
  box-sizing: border-box;
}
.bag-slot.has-item {
  background: #2d3756;
  color: #fff;
  font-weight: 500;
}



/* ==================== ✅ 反馈与设置弹窗 ==================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 18px 0;
  box-sizing: border-box;
}
.modal.show {
  display: flex !important;
}
.modal-content {
  background: var(--bg-card);
  padding: 16px;
  border-radius: 12px;
  width: min(92vw, 400px);
  min-height: 430px;
  max-width: 400px;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  overflow: visible;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  position: relative;
  border: 1px solid var(--bg-input);
}
.modal-content h2 {
  color: var(--color-gold);
  margin-bottom: 10px;
  font-size: 1.2em;
}
.modal-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--bg-input);
}
.modal-tab {
  background: none;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--color-text-light);
  transition: all 0.2s;
  font-size: 14px;
}
.modal-tab:hover {
  background: var(--bg-btn);
}
.modal-tab.active {
  background: var(--bg-btn);
  color: var(--color-gold);
}
.modal-tab-content {
  display: none;
  flex: 0 0 auto;
  overflow: visible;
  padding-right: 2px;
}
.modal-tab-content.active {
  display: flex;
  flex-direction: column;
}
.close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--color-text-light);
  transition: color 0.2s;
}
.close-btn:hover {
  color: var(--color-gold);
}
.feedback-message {
  margin: 16px 0;
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}
.email-box {
  background: var(--bg-input);
  padding: 14px;
  border-radius: 8px;
  text-align: center;
  margin: 18px 0;
  border: 1px solid #2a3b66;
}
.api-key-option {
  margin-bottom: 8px;
}
.api-key-section {
  margin-top: 10px;
}
.api-key-option {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}
.api-key-option:hover {
  background-color: rgba(255, 215, 0, 0.08);
}
.api-key-option input[type="radio"] {
  accent-color: var(--color-gold);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}
.option-content {
  flex: 1;
  text-align: left;
}
.option-content span {
  font-size: 14px;
  color: var(--color-text);
  display: block;
}
.option-desc {
  font-size: 12px;
  color: var(--color-text-light);
  margin-top: 3px;
}
.api-provider-select {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  justify-content: center;
  flex-wrap: nowrap;
}
.api-provider-select label {
  font-size: 14px;
  color: var(--color-text);
  white-space: nowrap;
}
.api-provider-select select {
  background: var(--bg-input);
  border: 1px solid var(--bg-border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--color-text);
  font-size: 14px;
  cursor: pointer;
  min-width: 160px;
}
.api-provider-select select:focus {
  outline: none;
  border-color: var(--color-gold);
}
.api-key-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--bg-border);
  border-radius: 8px;
  padding: 12px;
  color: var(--color-text);
  font-size: 14px;
  box-sizing: border-box;
}
.api-base-url-input,
.api-model-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--bg-border);
  border-radius: 8px;
  padding: 12px;
  color: var(--color-text);
  font-size: 14px;
  box-sizing: border-box;
  margin-top: 8px;
}
.api-key-input:focus {
  outline: none;
  border-color: var(--color-gold);
}
.api-key-note {
  font-size: 11px;
  color: var(--color-text-light);
  margin-top: 6px;
  line-height: 1.4;
}
.api-key-note a {
  color: var(--color-gold);
}
.api-advanced-toggle {
  width: 100%;
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px solid var(--bg-border);
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-light);
  cursor: pointer;
}
.api-advanced-toggle:hover {
  color: var(--color-gold);
  border-color: var(--color-gold);
}
.api-advanced-panel {
  display: none;
  margin-top: 8px;
}
.api-advanced-panel.show {
  display: block;
}
#api-status.success {
  background: rgba(46, 125, 50, 0.15);
  border: 1px solid rgba(46, 125, 50, 0.3);
}
#api-status.error {
  background: rgba(198, 40, 40, 0.15);
  border: 1px solid rgba(198, 40, 40, 0.3);
}
#api-status-text {
  font-size: 13px;
}
.email-box code {
  font-size: 16px;
  font-weight: bold;
  color: var(--color-gold);
}
.button-group {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
#copy-email {
  background: var(--bg-btn-action);
  color: white;
  border: none;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  flex: 1;
}
#copy-email:hover {
  background: var(--bg-btn-action-hover);
  transform: translateY(-1px);
}
#copy-email:active {
  transform: translateY(1px);
}
#cancel-feedback {
  background: var(--bg-btn);
  color: white;
  border: none;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  flex: 1;
}
#cancel-feedback:hover {
  background: var(--bg-btn-hover);
  transform: translateY(-1px);
}
#cancel-feedback:active {
  transform: translateY(1px);
}

/* 弹窗打开时禁用背景滚动 */
body.modal-open {
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden !important;
}
body.modal-open .container {
  width: 100%;
  max-width: 100%;
}

/* 反馈弹窗段落居中 */
#feedback-modal .modal-content p:nth-of-type(1) {
  text-align: center;
}

/* ==================== ✅ 反馈弹窗内 GitHub 链接 ==================== */
.feedback-github-link {
  text-align: center;
  margin: 10px 0;
}
.feedback-github-link a {
  color: #bea6eb;
  text-decoration: none;
  border-bottom: 1px dotted #aaa;
}

/* ==================== ✅ 页脚 ==================== */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.75rem;
  color: #aaa;
  background: transparent;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-family: inherit;
}
.site-footer a {
  color: #aaa;
  text-decoration: none;
  border-bottom: 1px dotted #aaa;
}
.site-footer p {
  margin-top: 0.5rem;
}

/* ==================== ✅ 魔药系统 ==================== */
/* 分类列表 一排三列 */
.potion-cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.potion-cat-btn {
  width: 100%; text-align: center; padding: 16px 10px;
  border: 1px solid #3a2a5c; border-radius: 10px;
  background: #2d1a3d; color: #f6e8ff;
  cursor: pointer; font-size: 14px; min-height: 100px; transition: all 0.2s;
}
.potion-cat-btn:hover { background: #442a5c; }
.potion-cat-icon { font-size: 26px; }
.potion-cat-name { font-weight: bold; color: #f8c850; margin: 4px 0; }
.potion-cat-desc { font-size: 11px; color: #e4c0ff; }
/* 配方列表 一排三列 */
.potion-recipe-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.potion-recipe-btn {
  width: 100%; text-align: left; padding: 12px;
  border-radius: 10px; background: #2d1a3d;
  border: 1px solid #3a2a5c; color: #f6e8ff;
  cursor: pointer; font-size: 13px; min-height: 110px; transition: all 0.2s;
}
.potion-recipe-btn:hover { background: #442a5c; }
.potion-recipe-btn.selected { border-color: #f8c850; background: #3a1a5c; }
.potion-recipe-btn.locked { opacity: 0.5; cursor: not-allowed; }
.potion-recipe-name { color: #f8c850; font-weight: bold; }
.potion-recipe-name.locked { color: #888; }
.potion-recipe-eng { font-size: 10px; color: #d8b8ff; }
.potion-recipe-prof { font-size: 10px; color: #c4a0e8; margin-top: 2px; }
.potion-recipe-lock { font-size: 10px; color: #ff8888; margin-top: 2px; }
.potion-recipe-effect { font-size: 10px; color: #c8b0e8; margin-top: 2px; }
.potion-recipe-mats { font-size: 10px; color: #d4b8f0; margin-top: 4px; }
/* ===================== 魔药炼制系统 样式注释版 ===================== */

/* 炼制台整体容器
 * 作用：整个魔药炼制界面的大背景、外框
 */
.brew-station {
  background: #1a1030;        /* 背景深紫色 */
  border-radius: 12px;         /* 圆角 */
  padding: 10px;               /* 内边距，让内容不贴边 */
  border: 1px solid #3a2a5c;   /* 边框颜色 */
  overflow: hidden !important; /* 隐藏超出部分 */
  max-height: none !important; /* 高度不限制 */
}

/* 炼制标题行
 * 作用：显示魔药图标 + 魔药名字 + 英文名称
 */
.brew-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid #3a2a5c;
}
.brew-title-row > div:nth-child(2) { flex: 1; } /* 名称区占满剩余，把熟练度推到右边 */

/* 魔药图标样式 */
.brew-icon { font-size: 28px; }

/* 魔药名称（黄色加粗） */
.brew-name { color: #f8c850; font-weight: bold; font-size: 16px; }

/* 魔药英文名称（淡紫色小字） */
.brew-eng { color: #d8b8ff; font-size: 11px; }

/* 熟练度徽章（右对齐） */
.brew-prof-badge { text-align: right; flex-shrink: 0; }
.brew-prof-num { color: #f8c850; font-size: 20px; font-weight: bold; line-height: 1; }
.brew-prof-pct { font-size: 12px; color: #c8a840; }
.brew-prof-bar {
  width: 64px; height: 4px; background: #2a1a40;
  border-radius: 2px; margin-top: 4px; overflow: hidden;
}
.brew-prof-fill { height: 100%; background: #f8c850; border-radius: 2px; transition: width 0.3s; }
.brew-prof-mastered { color: #f8c850; font-size: 13px; font-weight: bold; letter-spacing: 1px; }

/* 炼制工作区域
 * 作用：左边坩埚列 + 右边材料面板 的整体布局
 */
.brew-workarea {
  display: flex;              /* 左右分栏 */
  gap: 14px;                  /* 左右间距 */
  align-items: flex-start;    /* 顶部对齐 */
}

/* 坩埚列（左侧）
 * 作用：放坩埚、搅拌按钮、步骤提示
 */
.brew-cauldron-col {
  flex: 1;                        /* 自动占宽度 */
  display: flex;                  /* 纵向布局 */
  flex-direction: column;         /* 垂直排列 */
  align-items: center;            /* 水平居中 */
  min-width: 130px;               /* 最小宽度，防止变形 */
}

/* ===================== 课堂笔记 ===================== */
/* 笔记外框
 * 作用：显示炼制步骤的面板
 */
.prince-notes {
  background: #150d28;        /* 背景色 */
  border-radius: 12px;       /* 圆角 */
  padding: 8px 8px;          /* 内边距 */
  margin-bottom: 10px;       /* 底部间距 */
  width: 100%;               /* 宽度铺满 */
  border: 1px solid #3a2a5c; /* 边框 */
}

/* 笔记标题 */
.prince-notes-title {
  color: #d4a860;            /* 文字颜色 */
  font-size: 11px;           /* 字号 */
  text-align: left;          /* 左对齐 */
  margin-bottom: 6px;        /* 底部间距 */
  letter-spacing: 1px;       /* 字间距 */
}

/* 笔记步骤列表 */
.prince-notes-steps {
  display: flex;             /* 纵向排列 */
  flex-direction: column;
  gap: 4px;                  /* 步骤之间间距 */
  font-size: 10px;           /* 字号很小 */
}

/* 普通步骤（灰色） */
.prince-step { color: #8a7aaa; }

/* 已完成步骤（绿色+划线） */
.prince-step.done { color: #7aaa7a; text-decoration: line-through; }

/* 当前步骤（黄色加粗） */
.prince-step.current { color: #f8c850; font-weight: bold; }

/* ===================== 坩埚样式 ===================== */
/* 坩埚默认样式
 * 作用：圆形坩埚外观、阴影、边框
 */
.brew-cauldron {
  width: 150px; height: 150px;       /* 宽高固定，正圆 */
  border-radius: 50%;                /* 圆形 */
  background: radial-gradient(circle at 35% 35%, #3a3a3a, #111); /* 渐变金属质感 */
  border: 5px solid #4a3a22;         /* 边框 */
  box-shadow: 0 8px 20px #000, inset 0 -8px 12px #050505; /* 阴影+立体感 */
  display: flex; align-items: center; justify-content: center; /* 内部液体居中 */
  transition: all 0.3s;              /* 动画过渡 */
}

/* 搅拌状态：发光橙色 */
.brew-cauldron.stirring { box-shadow: 0 8px 20px #000, 0 0 20px #ff9a3c, inset 0 -8px 12px #050505; }

/* 炼制中：发光紫色 */
.brew-cauldron.brewing { border-color: #8060c8; box-shadow: 0 8px 20px #000, 0 0 30px #8060c8, inset 0 -8px 12px #050505; }

/* 炼制完成：发光金色 */
.brew-cauldron.done { border-color: #f8c850; box-shadow: 0 8px 20px #000, 0 0 30px #f8c850, inset 0 -8px 12px #050505; }

/* 炼制失败：发光红色 */
.brew-cauldron.fail { border-color: #6b3f48; box-shadow: 0 8px 20px #000, 0 0 20px #ff3030, inset 0 -8px 12px #050505; }

/* 混血王子光环特效 */
.brew-cauldron.prince-aura {
  border-color: #9b59b6;
  box-shadow: 0 8px 30px #000, 0 0 40px rgba(155, 89, 182, 0.6), inset 0 -8px 12px #050505;
  animation: princePulse 2s ease-in-out infinite;
}

/* 混血王子发光效果 */
.prince-glow {
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(155, 89, 182, 0.3) 0%, rgba(155, 89, 182, 0) 70%);
  animation: princeGlow 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes princePulse {
  0%, 100% { box-shadow: 0 8px 30px #000, 0 0 40px rgba(155, 89, 182, 0.6), inset 0 -8px 12px #050505; }
  50% { box-shadow: 0 8px 30px #000, 0 0 60px rgba(155, 89, 182, 0.8), inset 0 -8px 12px #050505; }
}

@keyframes princeGlow {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.1); opacity: 0.3; }
}

/* ===================== 坩埚内液体样式 ===================== */
.brew-liquid {
  width: 110px; height: 110px;        /* 液体大小 */
  border-radius: 50%;               /* 圆形 */
  transition: background 0.8s, box-shadow 0.8s; /* 颜色渐变动画 */
}

/* 初始液体（褐色） */
.brew-liquid.initial { background: #5a3020; box-shadow: inset 0 0 20px rgba(0,0,0,0.8); }

/* 过渡中液体（紫色） */
.brew-liquid.transitioning { background: #5040a0; box-shadow: inset 0 0 20px rgba(0,0,0,0.8), 0 0 20px rgba(160,140,200,0.5); }

/* 清澈液体（蓝色） */
.brew-liquid.clear { background: #b0d0e0; box-shadow: inset 0 0 20px #2c4b5e, 0 0 30px #aad4f0; }

/* 金色液体（成功） */
.brew-liquid.golden { background: #f4c542; box-shadow: inset 0 0 20px #b57c1c, 0 0 40px gold; }

/* 失败液体（黑色） */
.brew-liquid.fail { background: #1a0505; box-shadow: inset 0 0 20px rgba(0,0,0,0.9), 0 0 15px #ff3030; }

/* ===================== 搅拌按钮 ===================== */
/* 搅拌按钮行 */
.stir-row { display: flex; gap: 16px; margin-top: 8px; align-items: center; }

/* 搅拌按钮（左右旋转） */
.stir-btn {
  width: 42px; height: 42px;        /* 圆形按钮 */
  border-radius: 50%;
  border: 1px solid #5a4a7a;
  background: #2d1a3d;
  color: #c8b8e8;
  font-size: 22px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: all 0.2s;
}

/* 鼠标悬浮效果 */
.stir-btn:hover:not([disabled]) { background: #442a5c; border-color: #f8c850; }

/* 按钮禁用样式 */
.stir-btn[disabled] { opacity: 0.35; cursor: not-allowed; };

/* 搅拌次数显示（黄色） */
.stir-count { color: #f8c850; font-weight: bold; font-size: 16px; min-width: 30px; text-align: center; }

/* 液体状态文字 */
.brew-liq-label { color: #d4b8e0; font-size: 11px; margin-top: 4px; text-align: center; }

/* 清理一新按钮（重置炼制） */
.brew-reset-btn {
  margin-top: 6px;
  background: #3a2a5c;
  border: none;
  color: #e8d8f8;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  width: auto;
  transition: background 0.2s;
}
.brew-reset-btn:hover { background: #4a3a7c; }

/* ===================== 右侧材料面板 ===================== */
/* 右侧整体面板宽度 */
.brew-right-panel { flex: 1.2; display: flex; flex-direction: column; gap: 8px; }

/* 材料背包面板 */
.brew-mat-bag { 
  background: #150d28;
  border-radius: 10px;
  padding: 8px; 
  border: 1px solid #3a2a5c; 
}

/* 面板小标题 */
.brew-section-title { color: #f8c850; font-size: 12px; margin-bottom: 6px; }

/* 材料列表（自动换行） */
.brew-mat-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* 材料按钮 */
.brew-mat-btn {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid #3a2a5c;
  cursor: pointer;
  font-size: 11px;
  background: #2d1a3d;
  color: #d4c8e8;
  transition: all 0.15s;
}
.brew-mat-btn:hover:not([disabled]) { background: #442a5c; }

/* 材料已足够（绿色） */
.brew-mat-btn.done { background: #2a4a2a; opacity: 0.7; }

/* 材料不足（红色） */
.brew-mat-btn.short { color: #ff8888; }

/* 按钮禁用 */
.brew-mat-btn[disabled] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* 材料提示小字 */
.brew-mat-hint { font-size: 10px; color: #a090c0; margin-top: 4px; }

/* ===================== 材料处理台 ===================== */
.brew-prep { 
  background: #150d28;
  border-radius: 10px;
  padding: 8px; 
  border: 1px solid #3a2a5c; 
}

/* 处理台标题 */
.brew-prep-title { text-align: left; color: #d4a860 !important; }

/* 处理台背景 */
.brew-prep-table {
  background: linear-gradient(135deg, #1e1435, #281d45, #1e1435);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  border: 1px solid #3a2a5c;
}

/* 空置槽位（虚线框） */
.brew-prep-slot {
  background: #120d28;
  color: #d4a860;
  border: 2px dashed #4a3a6a;
  border-radius: 8px;
  padding: 10px;
  margin: 8px 0;
  min-height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 13px;
}

/* 处理台按钮组（垂直排列） */
.brew-prep-actions { display: flex; flex-direction: column; gap: 6px; width: 100%; }

/* 处理按钮 */
.brew-prep-btn {
  width: 100%;
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #3a2a5c;
  background: #2d1a3d;
  color: #d4c8e8;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.brew-prep-btn:hover:not([disabled]) { background: #442a5c; }
.brew-prep-btn[disabled] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* 处理提示 */
.brew-prep-hint { font-size: 10px; color: #a090c0; margin-top: 6px; text-align: center; }

/* ===================== 提示信息 ===================== */
.brew-hint {
  background: #150d28;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  font-size: 12px;
  color: #d4c8e8;
  margin-top: 10px;
  border: 1px solid #3a2a5c;
}

/* 全宽下一步提示条 */
.brew-hint-full {
  width: 100%;
  box-sizing: border-box;
  margin-top: 12px;
}

/* 补齐材料按钮（紫色） */
.potion-fill-btn { background: #5c2d7e !important; }
.potion-fill-btn:hover { background: #6e3a94 !important; }

/* ==================== ✅ 魔药系统：展开式布局 ==================== */
#pot-container {
  margin: 10px 0;
}

.potion-cat-grid,
.potion-recipe-grid {
  overflow: visible;
}

/* ====================== 📱 响应式适配 ====================== */
/* 平板 (768px 以下) */
@media (max-width: 768px) {
  .container {
    padding: 12px;
    max-width: 100%;
  }
  h1, h2 {
    font-size: 1.4rem;
    margin-bottom: 10px;
  }
  h3 {
    font-size: 1.1rem;
  }
  .title {
    font-size: 16px;
  }
  .info {
    font-size: 14px;
  }
  .btn {
    padding: 8px 12px;
    min-width: 70px;
    margin: 4px;
    font-size: 14px;
  }
  .log {
    height: 180px;
    padding: 10px;
    font-size: 13px;
  }
  .log-title {
    align-items: center;
  }
  .log-filters {
    flex: 0 1 auto;
    justify-content: flex-end;
  }
  input, select {
    padding: 8px 10px;
    font-size: 16px;
    margin: 6px 0;
  }
  .bag-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
  }
  .bag-slot {
    min-height: 40px;
    font-size: 11px;
  }
  #slotBox,
  #slotBox-create {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .slot-btn {
    padding: 10px 6px;
    font-size: 12px;
  }
  .timeline {
    margin: 8px 0;
    line-height: 1.5;
  }
  .event-date {
    width: 100px;
    font-size: 12px;
  }
}

/* 手机小屏 (480px 以下) */
@media (max-width: 480px) {
  .container {
    padding: 8px;
  }
  body {
    font-size: 13px;
  }
  h1 {
    font-size: 1.3rem;
    margin-bottom: 8px;
  }
  h2 {
    font-size: 1.1rem;
    margin-bottom: 8px;
  }
  h3 {
    font-size: 1rem;
    margin-bottom: 8px;
  }
  .title {
    font-size: 14px;
    margin-bottom: 8px;
  }
  .info {
    font-size: 13px;
    margin: 6px 0;
  }
  .card {
    padding: 10px;
    margin: 6px 0;
    border-radius: 8px;
  }
  .btn {
    padding: 8px 10px;
    min-width: 60px;
    margin: 3px;
    font-size: 13px;
    border-radius: 6px;
  }
  .btn-row, .random-row {
    gap: 4px;
  }
  .log {
    height: 190px;
    padding: 8px;
    font-size: 12px;
    margin: 6px 0;
  }
  .log-title {
    flex-direction: row;
    align-items: center;
    gap: 6px 8px;
  }
  .log-filters {
    width: auto;
    flex: 0 1 auto;
    justify-content: flex-end;
  }
  .log-filter {
    font-size: 11px;
  }
  .log p {
    margin: 2px 0;
  }
  input, select {
    padding: 8px 10px;
    font-size: 16px;
    margin: 4px 0;
    border-radius: 6px;
  }
  .chat-input-group {
    gap: 6px;
    margin-top: 8px;
  }
  .chat-input-group .btn {
    min-width: 60px;
    margin: 0;
  }
  .bag-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    margin-top: 6px;
  }
  .bag-slot {
    min-height: 36px;
    font-size: 10px;
    padding: 1px;
    border-radius: 4px;
  }
  .bag-tab-row {
    gap: 4px;
    margin: 6px 0;
  }
  .bag-tab {
    padding: 5px 8px;
    font-size: 12px;
    border-radius: 5px;
  }
  #slotBox,
  #slotBox-create {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    max-height: 400px;
    margin-right: 0;
  }
  .slot-btn {
    padding: 10px 8px;
    font-size: 11px;
  }
  .slot-desc {
    font-size: 10px;
    margin-top: 3px;
  }
  .save-btn {
    padding: 8px 10px;
    font-size: 13px;
  }
  .save-btn-row {
    gap: 6px;
  }
  .timeline {
    margin: 6px 0;
    line-height: 1.4;
  }
  .timeline h4 {
    margin: 6px 0 2px;
    font-size: 13px;
  }
  .timeline p {
    margin: 2px 0;
    font-size: 12px;
  }
  .event-date {
    display: block;
    width: 100%;
    margin-bottom: 4px;
  }
  .tl-story-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: flex-start;
    gap: 6px;
  }
  .tl-story-header .event-date {
    display: inline-block;
    width: auto;
    margin-bottom: 0;
    white-space: nowrap;
  }
  .tl-story-toggle {
    min-width: 0;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
  }
  .tl-story-badge {
    justify-self: end;
    white-space: nowrap;
  }
  .story-trigger-btn {
    grid-column: 1 / -1;
    width: 100%;
  }
  .stat {
    padding: 4px 8px;
    margin: 2px;
    font-size: 12px;
  }
  .action-btn {
    padding: 10px;
    margin: 4px 0;
    font-size: 14px;
    border-radius: 6px;
  }
  .action-grid {
    gap: 8px;
    margin-top: 8px;
  }
  .action-grid .action-btn {
    min-height: 46px;
    margin: 0;
  }
  .info-collapse-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
  #wand-result,
  #sorting-result {
    margin-top: 8px;
    padding: 10px;
    font-size: 13px;
  }
}

/* 超小屏 (320px 以下) */
@media (max-width: 320px) {
  .container {
    padding: 6px;
  }
  .btn {
    padding: 6px 8px;
    min-width: 50px;
    font-size: 12px;
  }
  .bag-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
  }
  .title {
    font-size: 13px;
  }
}/* ── 状态网格（2×2）──────────────────────────────────── */
.status-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  row-gap: 5px;
  align-items: center;
  font-size: 14px;
  color: var(--color-text, #e6e6e6);
  padding: 2px 0 6px;
  max-width: 100%;
  min-width: 0;
}

.world-paper {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(248, 200, 80, 0.22);
}

.world-paper-title {
  color: var(--color-gold);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.world-paper-content {
  display: grid;
  gap: 9px;
}

.world-paper-headline {
  color: rgba(245, 238, 220, 0.95);
  font-size: 12.5px;
  line-height: 1.5;
  padding: 7px 9px;
  background: rgba(248, 200, 80, 0.08);
  border-left: 3px solid var(--color-gold);
  border-radius: 4px;
  overflow-wrap: anywhere;
}

.world-paper-cta {
  color: #ffe9a8;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 9px;
  background: rgba(120, 90, 200, 0.18);
  border: 1px solid rgba(160, 130, 230, 0.4);
  border-radius: 4px;
}

.world-paper-section {
  display: grid;
  gap: 4px;
}

.world-paper-section-title {
  color: rgba(248, 200, 80, 0.72);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(248, 200, 80, 0.14);
}

.world-bond-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: rgba(230, 230, 230, 0.86);
}

.world-bond-pair {
  min-width: 0;
  overflow-wrap: anywhere;
}

.world-bond-band {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 9px;
}

.world-bond-band.band-warm {
  color: #7be0a0;
  background: rgba(80, 200, 130, 0.16);
}

.world-bond-band.band-neutral {
  color: #d8c98a;
  background: rgba(216, 201, 138, 0.14);
}

.world-bond-band.band-cold {
  color: #f0907f;
  background: rgba(220, 110, 90, 0.16);
}

.world-paper-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: rgba(230, 230, 230, 0.86);
  font-size: 12px;
  line-height: 1.45;
}

.world-paper-tag {
  color: #f8c850;
  font-weight: 700;
  white-space: nowrap;
}

.world-paper-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.world-paper-empty {
  color: var(--color-text-light);
  font-size: 12px;
}

.world-paper-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: rgba(248, 200, 80, 0.06);
  border: 1px solid rgba(248, 200, 80, 0.16);
  border-radius: 8px;
}

.world-paper-tab {
  flex: 1;
  min-width: 0;
  padding: 5px 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: rgba(245, 238, 220, 0.62);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.world-paper-tab.active {
  color: #1c1408;
  background: var(--color-gold);
}

.world-paper-tabbody {
  display: grid;
  gap: 6px;
  margin-top: 7px;
}

.world-paper-dateline {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(248, 200, 80, 0.7);
  margin-bottom: 4px;
}

.world-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 9px;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(235, 232, 222, 0.9);
  background: rgba(255, 255, 255, 0.035);
  border-left: 3px solid rgba(248, 200, 80, 0.4);
  border-radius: 4px;
}

.world-card-icon {
  flex: none;
  font-size: 14px;
  line-height: 1.35;
}

.world-card-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.world-card-kind {
  margin-right: 6px;
  font-weight: 700;
  white-space: nowrap;
}

.world-card-rumor { border-left-color: #c8a24a; }
.world-card-rumor .world-card-kind { color: #e3c069; }
.world-card-course { border-left-color: #6aa6e0; }
.world-card-course .world-card-kind { color: #8fc0f0; }
.world-card-relation { border-left-color: #7bd0a0; }
.world-card-relation .world-card-kind { color: #97e3b8; }
.world-card-affinity { border-left-color: #d68ad8; }
.world-card-affinity .world-card-kind { color: #e8a8ea; }
.world-card-followup { border-left-color: #d8b06a; }
.world-card-followup .world-card-kind { color: #ecc88a; }
.world-card-place { border-left-color: #8a9cd8; }
.world-card-place .world-card-kind { color: #aab8ec; }

.world-bond-glyph {
  margin-right: 5px;
}

.world-bond-link {
  color: rgba(248, 200, 80, 0.5);
}
.sg-left {
  min-width: 0;
  text-align: left;
  overflow-wrap: anywhere;
}
.sg-right {
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  color: #f8d49d;
  min-width: 0;
  max-width: 100%;
}
.sg-currency {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}
.coin-g { color: #ffd700; }
.coin-s { color: #c0c0c0; }
.coin-b { color: #cd7f32; }

.bag-emoji-btn {
  cursor: pointer;
  margin-left: 4px;
  font-size: 16px;
  display: inline-block;
  padding: 2px 4px;
  border-radius: 6px;
  border: 1px solid rgba(248,200,80,0.3);
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.bag-emoji-btn:hover {
  transform: scale(1.2);
  border-color: rgba(248,200,80,0.7);
  background: rgba(255,255,255,0.08);
}
.bag-emoji-btn:active {
  transform: scale(0.95);
}

.info-emoji-btn {
  cursor: pointer;
  margin-left: 4px;
  font-size: 16px;
  display: inline-block;
  padding: 2px 4px;
  border-radius: 6px;
  border: 1px solid rgba(248,200,80,0.3);
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.info-emoji-btn:hover {
  transform: scale(1.2);
  border-color: rgba(248,200,80,0.7);
  background: rgba(255,255,255,0.08);
}
.info-emoji-btn:active {
  transform: scale(0.95);
}

.ach-header-btn {
  cursor: pointer;
  font-size: 12px;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(248,200,80,0.3);
  color: #e6e6e6;
  background: rgba(255,255,255,0.04);
  margin-left: auto;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.ach-header-btn:hover {
  transform: scale(1.08);
  border-color: rgba(248,200,80,0.7);
  background: rgba(255,255,255,0.1);
}
.ach-header-btn:active {
  transform: scale(0.95);
}

/* ── 学院积分详细版 ────────────────────────────────────── */
.house-points-detail {
  margin-top: 12px;
  background: #161d2f;
  border: 1px solid #2a3b66;
  border-radius: 10px;
  padding: 12px 14px;
}
.hp-detail-title {
  font-size: 13px;
  font-weight: 700;
  color: #f8c850;
  margin-bottom: 10px;
}
.hourglasses {
  display: flex;
  justify-content: space-around;
  gap: 6px;
}
.hg-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.hg-label {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}
.hg-col[data-house="gryffindor"] .hg-label { color: #ff6b6b; }
.hg-col[data-house="slytherin"]  .hg-label { color: #6bdd6b; }
.hg-col[data-house="ravenclaw"]  .hg-label { color: #6b9fff; }
.hg-col[data-house="hufflepuff"] .hg-label { color: #ffd700; }
.hg-body {
  position: relative;
  width: 52px;
  height: 120px;
  display: flex;
  justify-content: center;
  filter: drop-shadow(0 0 1.5px rgba(255,255,255,0.35));
}
.hg-glass {
  position: relative;
  width: 44px;
  height: 120px;
  background: rgba(255,255,255,0.05);
  clip-path: polygon(
    5% 0%, 95% 0%,
    95% 30%, 55% 50%,
    95% 70%, 95% 100%,
    5% 100%,
    5% 70%, 45% 50%,
    5% 30%
  );
  overflow: hidden;
}
.hg-neck {
  display: none;
}
.hg-sand {
  position: absolute;
  bottom: 0;
  left: 3px;
  right: 3px;
  height: 0%;
  transition: height 0.6s ease;
  overflow: visible;
  z-index: 2;
}
.hg-orb {
  position: absolute;
  border-radius: 50%;
  opacity: 0.92;
}
.hg-col[data-house="gryffindor"] .hg-orb { background: radial-gradient(circle at 35% 35%, #ff9999, #dc143c); }
.hg-col[data-house="slytherin"]  .hg-orb { background: radial-gradient(circle at 35% 35%, #99ff99, #2e8b2e); }
.hg-col[data-house="ravenclaw"]  .hg-orb { background: radial-gradient(circle at 35% 35%, #99bbff, #4169e1); }
.hg-col[data-house="hufflepuff"] .hg-orb { background: radial-gradient(circle at 35% 35%, #ffed99, #ffd700); }
.hg-col[data-house="gryffindor"] .hg-sand { background: linear-gradient(0deg, rgba(220,20,60,0.3), transparent); }
.hg-col[data-house="slytherin"]  .hg-sand { background: linear-gradient(0deg, rgba(46,139,46,0.3), transparent); }
.hg-col[data-house="ravenclaw"]  .hg-sand { background: linear-gradient(0deg, rgba(65,105,225,0.3), transparent); }
.hg-col[data-house="hufflepuff"] .hg-sand { background: linear-gradient(0deg, rgba(255,215,0,0.3), transparent); }
.hg-score {
  font-size: 16px;
  font-weight: 700;
  color: #e6e6e6;
  text-align: center;
}
/* ── 信息页 2×2 网格 ──────────────────────────────────── */
.info-grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  margin-bottom: 12px;
}
.ig-cell {
  background: #161d2f;
  border: 1px solid #2a3b66;
  border-radius: 8px;
  padding: 10px 12px;
}
.ig-label {
  font-size: 13px;
  font-weight: 600;
  color: #f8c850;
  margin-bottom: 4px;
}
.ig-value {
  font-size: 14px;
  color: #8899aa;
  word-break: break-all;
}

/* ==================== 👥 好感度系统 ==================== */

/* ── 升级通知 ────────────────────────────────────────── */
.affinity-notif {
  position: fixed; bottom: 80px; right: 16px; z-index: 9999;
  background: #1e1235; border: 1px solid #5a3a8a;
  border-radius: 12px; padding: 12px 14px; min-width: 200px; max-width: 260px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 0 20px rgba(140,80,220,0.2);
  opacity: 0; transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
.affinity-notif.show { opacity: 1; transform: translateY(0); }
.affinity-notif-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.affinity-notif-icon { font-size: 20px; }
.affinity-notif-name { flex: 1; font-size: 13px; color: #f8c850; font-weight: bold; }
.affinity-notif-tier {
  font-size: 11px; background: #5a3a8a; color: #e8d8ff;
  padding: 2px 6px; border-radius: 10px;
}
.affinity-notif-desc { font-size: 11px; color: #c8b8e8; line-height: 1.5; }
.affinity-notif-unlock {
  font-size: 10px; color: #a0e8a0; margin-top: 5px;
  border-top: 1px solid #3a2a5c; padding-top: 5px;
}

/* ── 弹窗通用 ───────────────────────────────────────── */
.affinity-modal-overlay {
  position: fixed; inset: 0; z-index: 8888;
  background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.affinity-modal-box {
  background: #1a1030; border: 1px solid #3a2a5c;
  border-radius: 16px; padding: 20px;
  max-width: 380px; width: 100%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  max-height: 80vh; overflow-y: auto;
}

/* ── 偶遇弹窗 ───────────────────────────────────────── */
.affinity-enc-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.affinity-enc-icon { font-size: 24px; }
.affinity-enc-name { flex: 1; font-size: 15px; color: #f8c850; font-weight: bold; }
.affinity-enc-tag {
  font-size: 10px; background: #3a2a5c; color: #c8b8e8;
  padding: 2px 8px; border-radius: 10px;
}
.affinity-enc-text {
  font-size: 13px; color: #d8c8e8; line-height: 1.7;
  margin-bottom: 16px;
}
.affinity-enc-choices { display: flex; flex-direction: column; gap: 8px; }
.affinity-enc-choice-btn {
  background: #2d1a3d; border: 1px solid #3a2a5c;
  color: #d4c8e8; padding: 10px 14px; border-radius: 8px;
  font-size: 13px; text-align: left; cursor: pointer; transition: all 0.15s;
}
.affinity-enc-choice-btn:hover:not([disabled]) { background: #442a5c; border-color: #7a5aaa; }
.affinity-enc-choice-btn[disabled] { cursor: default; }
.affinity-enc-response {
  margin-top: 14px; padding: 12px; background: #150d28;
  border-radius: 10px; border: 1px solid #3a2a5c;
  font-size: 13px; color: #c8b8e8; line-height: 1.7;
}
.world-hook-source,
.world-hook-response {
  white-space: normal;
}
.world-hook-response {
  font-size: 13px;
}
.world-hook-source .story-text-block,
.world-hook-response .story-text-block {
  margin: 0 0 12px;
}
.world-hook-source .story-text-block:last-child,
.world-hook-response .story-text-block:last-child {
  margin-bottom: 0;
}
.world-hook-source .story-narration-block,
.world-hook-response .story-narration-block {
  color: #d8c8e8;
}
.world-hook-source .story-dialogue-block,
.world-hook-response .story-dialogue-block {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 3px solid #f8c850;
  background: rgba(32, 20, 52, 0.62);
  border-radius: 0 8px 8px 0;
}
.world-hook-source .story-inline-speaker,
.world-hook-response .story-inline-speaker {
  color: #f8c850;
}
.world-hook-source .story-dialogue-line,
.world-hook-response .story-dialogue-line {
  padding-left: 0;
  color: #efe8ff;
}
.world-hook-choices {
  margin-top: 14px;
}
.affinity-enc-close {
  display: block; width: 100%; margin-top: 12px;
  background: #3a2a5c; border: none; color: #e8d8f8;
  padding: 10px; border-radius: 8px; cursor: pointer;
  font-size: 13px; transition: background 0.2s;
}
.affinity-enc-close:hover { background: #4a3a7c; }

/* ── 总览面板 ───────────────────────────────────────── */
.affinity-panel-overlay {
  position: fixed; inset: 0; z-index: 8888;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 20px 16px; overflow-y: auto;
}
.affinity-panel-box {
  background: #1a1030; border: 1px solid #3a2a5c;
  border-radius: 16px; padding: 16px;
  max-width: 440px; width: 100%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.affinity-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; font-size: 15px; color: #f8c850; font-weight: bold;
}
.affinity-panel-header button {
  background: none; border: none; color: #8888aa;
  font-size: 16px; cursor: pointer; padding: 2px 6px;
}
.affinity-panel-grid { display: flex; flex-direction: column; gap: 10px; }
.affinity-char-card {
  background: #150d28; border: 1px solid #3a2a5c;
  border-radius: 12px; padding: 12px;
}
.affinity-char-top {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.affinity-char-icon { font-size: 22px; flex-shrink: 0; }
.affinity-char-info { flex: 1; }
.affinity-char-name { font-size: 13px; color: #f8c850; font-weight: bold; }
.affinity-char-role { font-size: 10px; color: #a090c0; margin-top: 2px; }
.affinity-char-tier-badge {
  background: #3a2a5c; color: #d8b8ff;
  font-size: 11px; padding: 3px 8px; border-radius: 10px; flex-shrink: 0;
}
.affinity-char-tier-label {
  font-size: 11px; color: #c8b8e8; margin-bottom: 8px; line-height: 1.5;
}
.affinity-char-bar-wrap {
  background: #2a1a40; border-radius: 3px; height: 4px;
  overflow: hidden; margin-bottom: 10px;
}
.affinity-char-bar { height: 100%; background: #8a5adc; border-radius: 3px; transition: width 0.4s; }
.affinity-char-bar-neg { background: #c0392b; }
.affinity-char-card-neg { border-color: rgba(192,57,43,0.3); }
.affinity-tier-badge-neg { background: #5a1a1a; color: #e74c3c; }
.affinity-tier-label-neg { color: #e74c3c; }
.affinity-char-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.affinity-char-btn {
  font-size: 11px; padding: 5px 10px; border-radius: 6px;
  border: 1px solid #3a2a5c; background: #2d1a3d;
  color: #d4c8e8; cursor: pointer; transition: all 0.15s;
}
.affinity-char-btn:hover { background: #442a5c; }

/* ── 故事/信件阅读 ──────────────────────────────────── */
.affinity-read-box { max-width: 420px; }
.affinity-read-tag {
  font-size: 10px; color: #a090c0; margin-bottom: 8px; letter-spacing: 1px;
}
.affinity-read-title {
  font-size: 15px; color: #f8c850; font-weight: bold; margin-bottom: 14px;
}
.affinity-read-body {
  font-size: 13px; color: #d4c8e8; line-height: 1.9;
  white-space: pre-line;
}

/* ── 好感度面板：分组布局 ── */
.affinity-panel-body {
  overflow-y: auto;
  flex: 1;
  padding: 0 4px;
}
.affinity-section {
  margin-bottom: 10px;
}
.affinity-section-title {
  font-size: 11px;
  color: #888;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 10px 4px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 8px;
}

.affinity-collapse-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 6px;
  transition: background 0.15s, border-color 0.15s;
}
.affinity-collapse-header:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
}
.affinity-collapse-header .affinity-section-title {
  border-bottom: none;
  padding: 0;
  margin-bottom: 0;
  flex: 1;
}
.affinity-collapse-count {
  background: rgba(255,255,255,0.1);
  color: #aaa;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
}
.affinity-collapse-arrow {
  font-size: 10px;
  color: #888;
  transition: transform 0.2s;
}
.affinity-collapse-header-closed .affinity-collapse-arrow {
  transform: rotate(0deg);
}
.affinity-collapse-header:not(.affinity-collapse-header-closed) .affinity-collapse-arrow {
  transform: rotate(90deg);
}
.affinity-collapse-body {
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  max-height: 2000px;
  opacity: 1;
}
.affinity-collapse-closed {
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

/* ── 主动聊聊按钮 ── */
.affinity-btn-chat {
  background: linear-gradient(135deg, #1a3a5c, #1e4a7a);
  border-color: #2a5a9a;
}
.affinity-btn-chat:hover:not([disabled]) {
  background: linear-gradient(135deg, #1e4a7a, #2460a0);
}
.affinity-btn-cooldown {
  opacity: 0.45;
  cursor: not-allowed !important;
  background: #222 !important;
  border-color: #333 !important;
}

/* ── Toast 轻提示 ── */
.affinity-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(20, 20, 40, 0.95);
  color: #ccc;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 99999;
  pointer-events: none;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.1);
}
.affinity-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── 人物关系面板：标签页 ── */
.aff-tab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.aff-tab-btn {
  flex: 1;
  background: #2d1a3d;
  border: 1px solid #3a2a5c;
  color: #c8b8e8;
  padding: 7px 4px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 11px;
  text-align: center;
  transition: all 0.15s;
  white-space: nowrap;
}
.aff-tab-btn:hover { background: #3a2a5c; }
.aff-tab-btn.active {
  background: #5a3a8a;
  color: #f8c850;
  border-color: #7a5aaa;
  font-weight: bold;
}
.aff-tab-pane { display: none; }
.aff-tab-pane.active { display: block; }

/* ── 内嵌模式（info 子页） ── */
.aff-inline-wrapper {
  padding: 0;
}
.aff-inline-wrapper .aff-tab-bar {
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.aff-inline-wrapper .affinity-panel-body {
  overflow-y: auto;
  max-height: 600px;
  padding: 0;
}

/* ==================== ✅ 好感度卡片：内嵌面板 2列网格 + 紧凑化 ==================== */

.aff-inline-wrapper .affinity-panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.aff-inline-wrapper .affinity-char-card {
  background: #150d28;
  border: 1px solid #2a1f45;
  border-radius: 10px;
  padding: 10px;
}

.aff-inline-wrapper .affinity-char-top {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
}

.aff-inline-wrapper .affinity-char-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.aff-inline-wrapper .affinity-char-name {
  font-size: 12px;
  color: #f8c850;
  font-weight: bold;
  line-height: 1.3;
}

.aff-inline-wrapper .affinity-char-role {
  font-size: 10px;
  color: #8a7aaa;
  margin-top: 1px;
}

.aff-inline-wrapper .affinity-char-tier-badge {
  background: #3a2a5c;
  color: #d8b8ff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  flex-shrink: 0;
  white-space: nowrap;
}

.aff-inline-wrapper .affinity-char-tier-label {
  font-size: 10px;
  color: #7a6a9a;
  line-height: 1.4;
  margin-bottom: 6px;
  /* stylelint-disable property-no-vendor-prefix -- 多行截断必须用 -webkit- 前缀 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.aff-inline-wrapper .affinity-char-bar-wrap {
  background: #2a1a40;
  border-radius: 3px;
  height: 5px;
  overflow: hidden;
  margin-bottom: 7px;
}

.aff-inline-wrapper .affinity-char-btn {
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid #3a2a5c;
  background: #2d1a3d;
  color: #c8b8e8;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.aff-inline-wrapper .affinity-char-btn:hover {
  background: #442a5c;
}

.aff-inline-wrapper .affinity-section-title {
  font-size: 11px;
  color: #8a7aaa;
  letter-spacing: 0.5px;
  text-transform: none;
  padding: 8px 4px 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 8px;
}

.aff-empty-tip {
  text-align: center;
  padding: 8px 10px;
  color: #5a4a7a;
  font-size: 12px;
  letter-spacing: 0.5px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.aff-empty-tip::before {
  content: '✦ ';
  font-size: 12px;
  color: #3a2a5c;
}

.aff-inline-wrapper .aff-tab-bar {
  margin-bottom: 8px;
  padding-bottom: 8px;
  gap: 5px;
}
.aff-inline-wrapper .aff-tab-btn {
  padding: 6px 4px;
  font-size: 11px;
}

.aff-inline-wrapper .affinity-panel-body {
  max-height: 520px;
  overflow-y: auto;
  padding: 0;
}

@media (max-width: 400px) {
  .aff-inline-wrapper .affinity-panel-grid {
    grid-template-columns: 1fr;
  }
}

.duel-second-tag {
  text-align: center;
  font-size: 12px;
  color: #c9a84c;
  padding: 4px 0;
  margin: 4px 0;
  border-top: 1px solid #2a3b66;
  border-bottom: 1px solid #2a3b66;
}

.gift-panel {
  background: #1a1a2e;
  border: 2px solid #3a3b66;
  border-radius: 12px;
  width: 90vw;
  max-width: 400px;
  max-height: 75vh;
  overflow-y: auto;
  padding: 16px;
  color: #e6e6e6;
}

.gift-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #2a3b66;
}

.gift-header-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gift-char-icon {
  font-size: 22px;
}

.gift-char-name {
  font-size: 15px;
  font-weight: bold;
  color: #f8c850;
}

.gift-close-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
}
.gift-close-btn:hover { color: #f66; }

.gift-prefs-section {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

.gift-pref-hint {
  font-size: 11px;
  color: #aaa;
  line-height: 1.6;
  margin-bottom: 2px;
}

.gift-items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.gift-item-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #1e293b;
  border: 1px solid #2a3b66;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.gift-item-card:hover {
  background: #2a3b66;
  border-color: #4a5b96;
}

.gift-item-icon {
  font-size: 22px;
  min-width: 28px;
  text-align: center;
}

.gift-item-info {
  flex: 1;
  min-width: 0;
}

.gift-item-name {
  font-size: 13px;
  color: #e6e6e6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gift-item-meta {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: #888;
  margin-top: 2px;
}

.gift-item-tier {
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap;
  min-width: 50px;
  text-align: right;
}

.gift-empty {
  text-align: center;
  padding: 20px;
  color: #5a4a7a;
  font-size: 13px;
}

.gift-tip {
  text-align: center;
  font-size: 10px;
  color: #666;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.gift-result-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gift-result-card {
  background: #1a1a2e;
  border: 2px solid #3a3b66;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  max-width: 320px;
  width: 85vw;
}

.gift-result-tier {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 8px;
}

.gift-result-item {
  font-size: 14px;
  color: #e6e6e6;
  margin-bottom: 8px;
}

.gift-result-delta {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 12px;
}

.gift-result-response {
  font-size: 13px;
  color: #bbb;
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 16px;
  padding: 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
}

.gift-result-ok {
  background: #3a3b66;
  border: 1px solid #5a6b96;
  color: #e6e6e6;
  padding: 8px 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.gift-result-ok:hover {
  background: #4a5b96;
}
