/* ============================================
   AI 生活数据故事 · 全局设计系统
   配色：暖橙主色 + 米白底 + 深棕文字
   字体：系统中文 + 苹方/微软雅黑
   ============================================ */

:root {
  /* 颜色 */
  --bg: #fbf8f3;
  --bg2: #f1ebde;
  --bg3: #fffdf8;
  --ink: #2a2520;
  --ink-soft: #4a3f33;
  --muted: #6b5d4a;
  --rule: #d8c9a8;
  --accent: #c75d3a;
  --accent-hover: #a8482a;
  --accent-soft: #e8d4c2;
  --accent2: #8a5a2b;
  --success: #5a8a4a;
  --warn: #d49a3a;
  --danger: #b3542f;
  --info: #6b7da3;

  /* 字体 */
  --font: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Consolas', monospace;

  /* 尺寸 */
  --max: 1080px;
  --max-text: 720px;
  --radius: 8px;
  --radius-lg: 12px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(42, 37, 32, 0.06);
  --shadow: 0 2px 8px rgba(42, 37, 32, 0.08);
  --shadow-lg: 0 8px 24px rgba(42, 37, 32, 0.12);

  /* 过渡 */
  --t-fast: 0.15s ease;
  --t: 0.25s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ============================================
   通用容器
   ============================================ */
.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container-text {
  max-width: var(--max-text);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ============================================
   顶栏
   ============================================ */
.topbar {
  background: var(--accent);
  color: #fff;
  padding: 0.8rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-brand:hover {
  color: #fff;
  text-decoration: none;
}

.topbar-brand .logo {
  width: 24px;
  height: 24px;
  background: #fff;
  color: var(--accent);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 900;
}

.topbar-nav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.88rem;
}

.topbar-nav a {
  color: rgba(255, 255, 255, 0.9);
}

.topbar-nav a:hover {
  color: #fff;
  text-decoration: none;
}

/* ============================================
   按钮
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius);
  transition: all var(--t);
  user-select: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-primary:disabled {
  background: var(--rule);
  color: var(--muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg2);
  color: var(--ink);
  border: 1px solid var(--rule);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}

.btn-ghost:hover {
  background: var(--bg2);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.05rem;
}

.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

/* ============================================
   卡片
   ============================================ */
.card {
  background: var(--bg3);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.2rem;
  transition: all var(--t);
}

.card-hover {
  cursor: pointer;
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

/* ============================================
   输入框
   ============================================ */
.input,
.textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--bg3);
  border: 1.5px solid var(--rule);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color var(--t-fast);
}

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.textarea {
  min-height: 100px;
  resize: vertical;
  font-family: inherit;
}

.input-counter {
  text-align: right;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

/* ============================================
   复选框
   ============================================ */
.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
  padding: 0.8rem 1rem;
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1.5px solid var(--rule);
  transition: all var(--t-fast);
}

.checkbox:hover {
  border-color: var(--accent);
}

.checkbox input[type="checkbox"] {
  margin-top: 0.15rem;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-text {
  flex: 1;
  font-size: 0.92rem;
  line-height: 1.5;
}

.checkbox-text small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.checkbox.checked {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ============================================
   徽标
   ============================================ */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 3px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-p0 { background: var(--accent); color: #fff; }
.badge-p1 { background: var(--accent2); color: #fff; }
.badge-p2 { background: var(--rule); color: var(--accent2); }
.badge-done { background: var(--success); color: #fff; }
.badge-warn { background: var(--warn); color: #fff; }

/* ============================================
   角色卡
   ============================================ */
.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.role-card {
  background: var(--bg3);
  border: 1.5px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--t);
  position: relative;
}

.role-card:hover:not(.disabled) {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.role-card.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.role-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin: 0 auto 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
}

.role-avatar.minmin { background: var(--accent); }
.role-avatar.jiejie { background: var(--accent2); }
.role-avatar.fangjie { background: var(--success); }

.role-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.2rem;
}

.role-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.role-desc {
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-bottom: 0.8rem;
}

.role-cta {
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 600;
}

/* ============================================
   数据卡
   ============================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.stat-card {
  background: var(--bg3);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
  margin-bottom: 0.3rem;
}

.stat-trend {
  font-size: 0.78rem;
  color: var(--muted);
}

.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ============================================
   数据源 chip
   ============================================ */
.source-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.9rem;
  background: var(--bg2);
  border: 1px solid var(--rule);
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--t-fast);
}

.source-chip:hover {
  border-color: var(--accent);
}

.source-chip.add {
  background: transparent;
  border-style: dashed;
  color: var(--accent);
}

.source-chip.connected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent2);
}

/* ============================================
   场景 chip
   ============================================ */
.scenario-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0;
}

.scenario-chip {
  padding: 0.55rem 1rem;
  background: var(--bg2);
  border-radius: 20px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--t-fast);
  border: 1px solid transparent;
}

.scenario-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.scenario-chip.active {
  background: var(--accent);
  color: #fff;
}

/* ============================================
   故事卡片
   ============================================ */
.story-card {
  background: var(--bg3);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.2rem;
  position: relative;
}

.story-card-num {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--bg2);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
}

.story-card-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.3rem;
}

.story-card-subtitle {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.story-card-chart {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
  min-height: 200px;
}

.story-card-insight {
  font-size: 0.92rem;
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 0.8rem 0;
  padding: 0.8rem;
  background: var(--bg2);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}

.story-card-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--rule);
}

/* ============================================
   加载/空/错误
   ============================================ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--bg2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

.error {
  background: #fef0eb;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 1rem;
  border-radius: var(--radius);
  margin: 1rem 0;
  font-size: 0.9rem;
}

/* ============================================
   模式横幅
   ============================================ */
.mode-banner {
  background: var(--warn);
  color: #fff;
  padding: 0.6rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
}

.mode-banner .icon {
  margin-right: 0.3rem;
}

/* ============================================
   卡片瀑布
   ============================================ */
.cards-masonry {
  column-count: 2;
  column-gap: 1rem;
  margin: 1.5rem 0;
}

.cards-masonry > * {
  break-inside: avoid;
  margin-bottom: 1rem;
}

@media (max-width: 720px) {
  .cards-masonry { column-count: 1; }
  .topbar-nav { display: none; }
  .container { padding: 0 1rem; }
}

/* ============================================
   工具类
   ============================================ */
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-small { font-size: 0.85rem; }
.text-tiny { font-size: 0.75rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ============================================
   隐私页
   ============================================ */
.privacy-section {
  background: var(--bg3);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
}

.privacy-section h3 {
  font-size: 1rem;
  color: var(--accent2);
  margin-bottom: 0.5rem;
}

.privacy-section p {
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.6;
}
