/* ── 全局重置 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── 亮色主题（默认）── */
:root {
  --c-bg:           #fafaf8;
  --c-white:        #fff;
  --c-text:         #1a1a1a;
  --c-text-2:       #555;
  --c-text-muted:   #888;
  --c-accent:       #c45a2c;
  --c-accent-light: #f5ebe6;
  --c-accent-dark:  #8b3a18;
  --c-border:       #e5e0da;
  --c-dark:         #1a1a1a;
  --c-surface:      #fff;
  --font:           'Noto Sans SC', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --max-width:      1100px;
  --content-width:  800px;
  --radius:         10px;
}

/* ── 暗色主题 ── */
[data-theme="dark"] {
  --c-bg:           #0f1117;
  --c-white:        #1a1d27;
  --c-text:         #e8eaf0;
  --c-text-2:       #9ca3b4;
  --c-text-muted:   #6b7280;
  --c-accent:       #e06830;
  --c-accent-light: #2a1a0e;
  --c-accent-dark:  #f08050;
  --c-border:       #2e3247;
  --c-dark:         #0a0c12;
  --c-surface:      #1a1d27;
}

html { font-size: 17px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--c-bg); color: var(--c-text); line-height: 1.6; transition: background .25s, color .25s; }

/* ── 顶部导航 ── */
.lesson-nav {
  background: var(--c-dark);
  padding: 0.75rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.lesson-nav a { color: rgba(255,255,255,.65); text-decoration: none; font-size: 0.9rem; transition: color .2s; }
.lesson-nav a:hover { color: #fff; }
.lesson-nav .sep { color: rgba(255,255,255,.3); }
.lesson-nav .lesson-title { color: #fff; font-weight: 600; font-size: 0.9rem; }

/* 主题切换按钮（嵌入导航右侧）*/
.theme-toggle {
  margin-left: 6px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.8);
  border-radius: 20px;
  padding: 0.2rem 0.8rem;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: var(--font);
  transition: background .2s;
  white-space: nowrap;
}
.theme-toggle:hover { background: rgba(255,255,255,.2); }

/* ── 主内容区 ── */
.lesson-wrap { max-width: var(--content-width); margin: 0 auto; padding: 2.5rem 2rem 5rem; }

/* ── 标题 ── */
h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 900; margin-bottom: 0.5rem; color: var(--c-text); }
h2 {
  font-size: 1.4rem; font-weight: 700; color: var(--c-text);
  display: inline-block;
  border-bottom: 2px solid var(--c-accent);
  padding-bottom: 0.25rem;
  margin: 2rem 0 0.3rem;
}
h3 { font-size: 1.1rem; font-weight: 600; margin: 1.4rem 0 0.5rem; color: var(--c-text); }
p  { color: var(--c-text-2); margin-bottom: 0.7rem; font-size: 1rem; }
p strong { color: var(--c-text); }
.section-subtitle { font-size: 1rem; color: var(--c-text-muted); margin-bottom: 1rem; }

/* ── 分隔线 ── */
hr { border: none; border-top: 1px solid var(--c-border); margin: 2rem 0; }

/* ── 卡片 ── */
.card {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin-bottom: 1rem;
  position: relative;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--c-accent);
  border-radius: var(--radius) var(--radius) 0 0;
}
.card h3 { margin-top: 0; }

/* highlight box */
.highlight-box {
  background: var(--c-accent-light);
  border-left: 4px solid var(--c-accent);
  padding: 1rem 1.2rem;
  margin: 1rem 0;
  border-radius: 0 6px 6px 0;
}
.highlight-box p { margin: 0; color: var(--c-text); }

/* dark box */
.dark-box {
  background: var(--c-accent-light);
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-accent);
  padding: 1.2rem 1.5rem;
  margin: 1rem 0;
  border-radius: 0 8px 8px 0;
}
.dark-box p { color: var(--c-text-2); }
.dark-box p:last-child { margin-bottom: 0; }

/* quote */
.quote {
  background: var(--c-white);
  border-left: 4px solid var(--c-accent);
  padding: 1rem 1.2rem;
  margin: 0.8rem 0;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--c-text);
}

/* ── 按钮 ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0.55rem 1.5rem;
  border-radius: 6px; border: none; cursor: pointer;
  font-size: 0.95rem; font-weight: 600;
  text-decoration: none;
  transition: background .2s;
  font-family: var(--font);
}
.btn-primary { background: var(--c-accent); color: #fff; }
.btn-primary:hover { background: var(--c-accent-dark); }
.btn-ghost { background: transparent; color: var(--c-text-2); border: 1px solid var(--c-border); }
.btn-ghost:hover { border-color: var(--c-accent); color: var(--c-accent); }

/* ── 表单 ── */
input[type=text], input[type=password], textarea, select {
  width: 100%;
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  color: var(--c-text);
  padding: 0.55rem 0.9rem;
  font-size: 0.95rem;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s, background .25s;
}
input:focus, textarea:focus, select:focus { border-color: var(--c-accent); }
textarea { resize: vertical; min-height: 80px; }

/* ── 标签 ── */
.tag {
  display: inline-block; padding: 0.15rem 0.7rem;
  border-radius: 3px; font-size: 0.8rem; font-weight: 600;
  background: var(--c-accent); color: #fff;
}
.tag-outline {
  background: transparent; color: var(--c-text-muted);
  border: 1px solid var(--c-border); border-radius: 3px;
  padding: 0.15rem 0.7rem; font-size: 0.8rem;
}

/* ── 流式输出区域 ── */
.output-box {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  min-height: 60px;
  font-size: 0.95rem;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--c-text);
  transition: background .25s;
}
.output-box.empty { color: var(--c-text-muted); font-style: italic; }

/* ── 预设问题 ── */
.preset-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  padding: 0.35rem 0.9rem;
  background: var(--c-white); border: 1px solid var(--c-border);
  border-radius: 20px; font-size: 0.88rem; color: var(--c-text-2);
  cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--c-accent); color: var(--c-accent); background: var(--c-accent-light); }

/* ── 表格 ── */
table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.95rem; }
th { background: var(--c-accent-light); padding: 0.6rem 0.8rem; text-align: left; font-weight: 600; color: var(--c-text); border-bottom: 2px solid var(--c-accent); }
td { padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--c-border); color: var(--c-text-2); }
tr:last-child td { border-bottom: none; }

/* ── 课程页脚 ── */
.lesson-footer {
  display: flex; justify-content: space-between;
  margin-top: 3rem; padding-top: 1.5rem;
  border-top: 1px solid var(--c-border);
}

/* ── 代码 ── */
code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  background: var(--c-accent-light);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--c-accent);
}

/* ── 响应式 ── */
@media (max-width: 600px) {
  .lesson-wrap { padding: 1.5rem 1rem 4rem; }
  h1 { font-size: 1.4rem; }
  .lesson-footer { flex-direction: column; gap: 0.8rem; }

  /* 顶部导航：移动端只保留首页链接 + 当前标题，隐藏中间层级 */
  .lesson-nav { padding: 0.6rem 1rem; gap: 0.4rem; flex-wrap: nowrap; }
  .lesson-nav .sep { display: none; }
  /* 隐藏除第一个和最后一个子元素之外的 a 标签（中间层级） */
  .lesson-nav > a:not(:first-child) { display: none; }
  .lesson-nav .lesson-title {
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
  }
  .lesson-nav > a:first-child { white-space: nowrap; font-size: 0.82rem; }
  .theme-toggle { margin-left: auto; padding: 0.15rem 0.6rem; font-size: 0.72rem; }

  /* 移动端隐藏次要状态按钮，只保留 LLM 主状态 */
  #tuzi-status-btn,
  #minimax-status-btn { display: none !important; }

  /* 工具箱按钮缩短 */
  #llm-widget > a { padding: 0.15rem 0.5rem !important; font-size: 0.72rem !important; }
  #llm-status-btn { padding: 0.15rem 0.5rem !important; font-size: 0.72rem !important; }
}
