/* ==================== 变量 ==================== */
:root {
  --bg: #F5F2EC;
  --text-primary: #1C1C1E;
  --text-secondary: #8E8E93;
  --text-tertiary: #C7C7CC;
  --accent: #D9C89A;
  --accent-deep: #C4B080;
  --glass-bg: rgba(255, 255, 255, 0.42);
  --glass-border: rgba(255, 255, 255, 0.75);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 14px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --same-bg: rgba(168, 194, 160, 0.22);
  --same-text: #5F7A56;
  --diff-bg: rgba(214, 158, 158, 0.22);
  --diff-text: #B06A6A;
  --missing-bg: rgba(217, 200, 154, 0.35);
  --missing-text: #8A7A4A;
}
[data-theme="dark"] {
  --bg: #1A1815;
  --text-primary: #F2F0EB;
  --text-secondary: #9A9691;
  --text-tertiary: #5A5854;
  --glass-bg: rgba(40, 38, 32, 0.55);
  --glass-border: rgba(255, 255, 255, 0.1);
  --same-bg: rgba(100, 130, 100, 0.25);
  --same-text: #A5C4A0;
  --diff-bg: rgba(180, 100, 100, 0.25);
  --diff-text: #E0A0A0;
  --missing-bg: rgba(217, 200, 154, 0.25);
  --missing-text: #D9C89A;
}

/* ==================== 基础 ==================== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro", "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
}

/* ==================== 容器与背景 ==================== */
.app-container { display: flex; flex-direction: column; height: 100vh; max-width: 1240px; margin: 0 auto; position: relative; padding: 16px; }
.bg-layer { position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5; }
.blob-1 { width: 500px; height: 500px; top: -180px; left: -140px; background: radial-gradient(circle, #EDE2C4 0%, transparent 70%); }
.blob-2 { width: 600px; height: 600px; bottom: -250px; right: -180px; background: radial-gradient(circle, #F2EAD3 0%, transparent 70%); }
.particle-canvas { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.bg-noise {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
}

/* ==================== 玻璃 ==================== */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px rgba(0,0,0,0.04), inset 0 1px 1px rgba(255,255,255,0.6);
}

/* ==================== 顶部 ==================== */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; margin-bottom: 16px; border-radius: var(--radius-lg); flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 36px; height: 36px; object-fit: contain; animation: float-gif 3s ease-in-out infinite; }
.brand-name { font-size: 16px; font-weight: 500; letter-spacing: 0.05em; }
.brand-sub { font-size: 10px; color: var(--text-secondary); letter-spacing: 0.1em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 8px; border-radius: 50%; transition: background 0.3s; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: rgba(255,255,255,0.3); }

/* ==================== 页面容器 ==================== */
.page-container { flex: 1; overflow-y: auto; position: relative; padding-bottom: 90px; -webkit-overflow-scrolling: touch; }
.page { display: none; flex-direction: column; gap: 16px; animation: fadeIn 0.4s var(--ease); }
.page.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes float-gif { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* ==================== 面板 ==================== */
.panel { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary); }
.panel-title img { width: 24px; height: 24px; object-fit: contain; animation: float-gif 3s ease-in-out infinite; }

/* ==================== 表单 ==================== */
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 11px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary); padding-left: 4px; }
textarea, input[type="text"], .glass-input {
  width: 100%; padding: 14px 16px; font-family: inherit; font-size: 14px;
  background: rgba(255,255,255,0.4); border: 1px solid var(--glass-border);
  border-radius: var(--radius-md); color: var(--text-primary); outline: none;
  transition: all 0.3s var(--ease);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
textarea::placeholder, input::placeholder { color: var(--text-tertiary); font-weight: 300; }
textarea:focus, input[type="text"]:focus, .glass-input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217, 200, 154, 0.2);
}

/* ==================== 下拉 ==================== */
.dropdown { position: relative; }
.dropdown-trigger {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  padding: 14px 16px; cursor: pointer; border-radius: var(--radius-md);
  color: var(--text-primary); font-size: 14px; font-family: inherit;
  transition: all 0.3s var(--ease); border: 1px solid transparent;
}
.dropdown-trigger:disabled { opacity: 0.5; cursor: not-allowed; }
.dropdown-text.placeholder { color: var(--text-tertiary); }
.chevron { width: 14px; height: 14px; transition: transform 0.3s; flex-shrink: 0; }
.dropdown.open .chevron { transform: rotate(180deg); }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  max-height: 0; overflow: hidden; opacity: 0; transform: translateY(-6px);
  transition: all 0.3s var(--ease); z-index: 100; padding: 0;
  border-radius: var(--radius-md);
}
.dropdown.open .dropdown-menu { max-height: 260px; opacity: 1; transform: translateY(0); padding: 6px; overflow-y: auto; }
.dropdown-item { padding: 10px 14px; border-radius: 10px; cursor: pointer; font-size: 13px; transition: background 0.2s; }
.dropdown-item:hover { background: rgba(217, 200, 154, 0.2); }
.dropdown-item.selected { background: rgba(217, 200, 154, 0.3); font-weight: 500; }

/* ==================== 按钮 ==================== */
.btn {
  display: flex; justify-content: center; align-items: center; gap: 8px;
  padding: 14px 20px; border: none; border-radius: var(--radius-md);
  font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.3s var(--ease);
}
.btn-primary { background: linear-gradient(180deg, #F2E9D2, #E4D6AE); color: #5A4E33; box-shadow: 0 4px 14px rgba(190, 170, 125, 0.2); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(190, 170, 125, 0.3); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary { background: rgba(255,255,255,0.55); color: var(--text-primary); border: 1px solid var(--glass-border); box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.btn-secondary:hover { background: rgba(255,255,255,0.75); transform: translateY(-1px); }
.btn-secondary:active { transform: translateY(1px); }
.btn-outline { background: transparent; border: 1px solid var(--accent); color: var(--text-primary); }
.btn-outline:hover { background: rgba(217,200,154,0.15); }
.btn img { width: 18px; height: 18px; object-fit: contain; }

.btn-row { display: flex; gap: 12px; width: 100%; margin-top: 8px; }
.btn-row .btn { flex: 1; padding: 12px 16px; border-radius: 999px; font-size: 14px; }

.ghost-btn {
  background: rgba(255,255,255,0.4); border: 1px solid var(--glass-border);
  padding: 6px 14px; border-radius: 999px; font-size: 12px;
  cursor: pointer; color: var(--text-secondary); transition: all 0.3s;
  font-family: inherit;
}
.ghost-btn:hover { background: rgba(255,255,255,0.7); color: var(--text-primary); }
.ghost-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ==================== 结果展示 ==================== */
.result-panel { min-height: 400px; }

.summary-area {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-around;
  gap: 20px;
  padding: 10px 0;
  flex-wrap: wrap;
}
.ring { position: relative; width: 110px; height: 110px; flex-shrink: 0; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: rgba(217, 200, 154, 0.2); stroke-width: 8; }
.ring-progress { fill: none; stroke: var(--accent-deep); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease); }
.ring-label { position: absolute; inset: 0; display: flex; justify-content: center; align-items: center; font-size: 20px; font-weight: 300; }

.stat-blocks { display: flex; gap: 12px; flex: 1; min-width: 200px; justify-content: space-around; }
.stat-block {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: rgba(255,255,255,0.2); padding: 12px 16px;
  border-radius: var(--radius-md); flex: 1; min-width: 70px;
}
.stat-value { font-size: 20px; font-weight: 500; }
.stat-value.same { color: var(--same-text); }
.stat-value.diff { color: var(--diff-text); }
.stat-label { font-size: 11px; color: var(--text-secondary); letter-spacing: 0.05em; }

.progress-section { display: flex; flex-direction: column; gap: 8px; }
.progress-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); }
.progress-track { height: 8px; background: rgba(217, 200, 154, 0.2); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #F2E9D2, #C4B080); border-radius: 999px; transition: width 1s var(--ease); }

.keyword-section { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-top: 1px solid var(--glass-border); border-bottom: 1px solid var(--glass-border); }
.keyword-head { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.keyword-head img { width: 16px; height: 16px; animation: float-gif 3s ease-in-out infinite; }
.keyword-list { display: flex; flex-wrap: wrap; gap: 6px; }
.keyword-item { background: rgba(217, 200, 154, 0.3); color: #6B5C36; font-size: 11px; padding: 4px 10px; border-radius: 999px; }
.empty-keyword { font-size: 12px; color: var(--text-tertiary); }

.legend { display: flex; gap: 16px; font-size: 11px; color: var(--text-secondary); justify-content: center; padding: 8px 0; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.same { background: var(--same-text); }
.dot.diff { background: var(--diff-text); }
.dot.miss { background: var(--missing-text); }

/* ★ 差异对比：永远竖向平铺 */
.diff-container {
  display: flex !important;
  flex-direction: column !important;
  gap: 16px !important;
  width: 100% !important;
}
.diff-block {
  width: 100% !important;
  padding: 16px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(255,255,255,0.2);
}
.diff-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 500; text-transform: uppercase;
  color: var(--text-secondary); margin-bottom: 12px;
}
.diff-head img { width: 18px; height: 18px; animation: float-gif 3s ease-in-out infinite; }
.diff-body {
  font-family: "SF Mono", "JetBrains Mono", "Menlo", monospace;
  font-size: 12px; line-height: 1.8;
  white-space: pre-wrap; word-break: break-all;
  max-height: 400px; overflow-y: auto;
  background: rgba(0,0,0,0.02); padding: 12px; border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}
.hl-same { background: var(--same-bg); color: var(--same-text); border-radius: 3px; padding: 1px 2px; }
.hl-diff { background: var(--diff-bg); color: var(--diff-text); border-radius: 3px; padding: 1px 2px; }
.hl-miss { background: var(--missing-bg); color: var(--missing-text); border-radius: 3px; padding: 1px 2px; }

/* ==================== 底部导航 ==================== */
.bottom-nav {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  width: calc(100% - 32px); max-width: 520px;
  display: flex; justify-content: space-around; padding: 8px;
  border-radius: 999px; z-index: 100;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer; padding: 6px 10px;
  border-radius: 999px; transition: all 0.3s var(--ease); color: var(--text-tertiary);
  font-family: inherit;
}
.nav-item img { width: 24px; height: 24px; object-fit: contain; filter: grayscale(100%); opacity: 0.6; transition: all 0.3s; }
.nav-item span { font-size: 10px; font-weight: 500; letter-spacing: 0.05em; }
.nav-item.active { background: rgba(255,255,255,0.6); color: var(--text-primary); box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.nav-item.active img { filter: grayscale(0%); opacity: 1; }

/* ==================== 弹窗 ==================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; justify-content: center; align-items: center;
  padding: 20px; background: rgba(0,0,0,0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.modal-content {
  width: 100%; max-width: 480px; padding: 24px;
  border-radius: var(--radius-xl);
  display: flex; flex-direction: column; gap: 16px;
  animation: modalIn 0.4s var(--ease);
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 18px; font-weight: 400; }
.close-btn { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-secondary); line-height: 1; padding: 0 4px; }
.modal-body { min-height: 60px; font-size: 14px; line-height: 1.7; color: var(--text-secondary); }
.modal-body img { width: 80px; height: 80px; object-fit: contain; animation: float-gif 3s ease-in-out infinite; }
.modal-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.step-dots { display: flex; gap: 6px; }
.step-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-tertiary); transition: all 0.3s; }
.step-dot.active { width: 18px; border-radius: 999px; background: var(--accent-deep); }
.modal-actions { display: flex; gap: 8px; }
.tutorial-options { display: flex; justify-content: center; padding: 4px 0; }
.tutorial-checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.tutorial-checkbox input { accent-color: var(--accent-deep); width: 16px; height: 16px; }
.tutorial-btns { display: flex; gap: 10px; width: 100%; }
.tutorial-btns .btn { flex: 1; padding: 12px 16px; border-radius: 999px; font-size: 14px; }

/* ==================== Toast ==================== */
.toast {
  position: fixed; bottom: 100px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none;
  transition: all 0.4s var(--ease); z-index: 300;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
  color: var(--text-primary);
  box-shadow: 0 16px 40px rgba(170,152,110,0.2);
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==================== 空状态 / 列表 ==================== */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 40px 0; color: var(--text-tertiary); }
.empty-state img { width: 80px; height: 80px; object-fit: contain; opacity: 0.6; animation: float-gif 3s ease-in-out infinite; }
.community-list, .preset-manage-list, .history-list { display: flex; flex-direction: column; gap: 12px; }
.community-card, .preset-group-card, .history-card {
  padding: 16px; background: rgba(255,255,255,0.3);
  border: 1px solid var(--glass-border); border-radius: var(--radius-md);
  display: flex; flex-direction: column; gap: 8px;
}
.community-card-header { display: flex; justify-content: space-between; align-items: center; font-weight: 500; gap: 10px; }
.community-card-meta { font-size: 12px; color: var(--text-tertiary); flex-shrink: 0; }

/* ==================== 设置 ==================== */
.settings-group { display: flex; flex-direction: column; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--glass-border); }
.settings-group:last-child { border-bottom: none; }
.settings-group h3 { font-size: 13px; font-weight: 500; text-transform: uppercase; color: var(--text-secondary); letter-spacing: 0.1em; }
.setting-item { display: flex; justify-content: space-between; align-items: center; font-size: 14px; gap: 12px; flex-wrap: wrap; }

/* ================================================================ */
/* ★★★ 响应式：核心修复 ★★★ */
/* 移动端立即切换为单列，避免结果面板被压扁                       */
/* ================================================================ */
@media (max-width: 900px) {
  .app-container { padding: 12px; }
  .panel { padding: 20px; }
  .summary-area { flex-direction: column; }
  .stat-blocks { width: 100%; }
}

@media (max-width: 640px) {
  .app-container { padding: 10px; }
  .panel { padding: 16px; gap: 14px; }
  .topbar { padding: 10px 14px; }
  .brand-name { font-size: 14px; }
  .brand-logo { width: 32px; height: 32px; }
  .stat-blocks { gap: 8px; }
  .stat-block { padding: 10px 8px; min-width: 60px; }
  .stat-value { font-size: 18px; }
  .ring { width: 96px; height: 96px; }
  .ring-label { font-size: 18px; }
  .btn-row .btn { font-size: 13px; padding: 11px 10px; }
  .btn-row .btn img { width: 16px; height: 16px; }
  .diff-body { font-size: 11.5px; padding: 10px; }
  .bottom-nav { bottom: 10px; padding: 6px; }
  .nav-item { padding: 6px 8px; }
  .nav-item img { width: 22px; height: 22px; }
  .nav-item span { font-size: 9px; }
  .toast { bottom: 88px; font-size: 12px; padding: 10px 18px; }
}