/* ============================================================
   游戏原画学习之路 · 交互式课堂 —— 全局样式（深色主题）
   ============================================================ */
:root {
  --bg: #101218;
  --panel: #181b23;
  --panel2: #20242f;
  --border: #2a2f3d;
  --text: #e6e9f0;
  --muted: #9aa3b5;
  --muted2: #6b7488;
  --accent: #f0a35e;   /* 主题琥珀色 */
  --accent2: #6fb7ff;  /* 辅助蓝 */
  --good: #5ecc8f;
  --bad: #ef6f6f;
  --dark-ink: #1a1206;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.7;
}
::selection { background: var(--accent); color: var(--dark-ink); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2f3d; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #394052; }

#app { display: flex; height: 100vh; overflow: hidden; }

/* ---------------- 侧边栏 ---------------- */
#sidebar {
  width: 292px; flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding-bottom: 20px;
}
.side-head { padding: 22px 18px 16px; border-bottom: 1px solid var(--border); }
.side-title { display: block; font-size: 17px; font-weight: 700; color: var(--text); text-decoration: none; }
.side-title:hover { color: var(--accent); }
.side-sub { font-size: 12px; color: var(--muted2); margin: 4px 0 14px; }
.progress-bar { height: 8px; background: #262b38; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #ffd08a); transition: width .35s ease; }
.side-progress-text { font-size: 11px; color: var(--muted); margin-top: 6px; }
.side-stage { margin-top: 12px; }
.side-stage-name { padding: 8px 18px 6px; font-size: 12px; font-weight: 700; letter-spacing: 1px; color: var(--muted); }
.side-stage-name span { display: block; font-size: 10.5px; font-weight: 400; color: var(--muted2); letter-spacing: 0; }
.side-lesson {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px; font-size: 13.5px;
  color: var(--text); text-decoration: none;
  border-left: 3px solid transparent;
}
.side-lesson:hover { background: rgba(255,255,255,.03); }
.side-lesson.active { border-left-color: var(--accent); background: var(--panel2); color: var(--accent); }
.side-lesson-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-check {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #262b38; font-size: 11px; color: var(--muted);
}
.side-lesson.done .side-check { background: rgba(94,204,143,.18); color: var(--good); }
.side-foot { margin-top: 18px; padding: 14px 18px 0; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted2); }

/* ---------------- 主区域 ---------------- */
#main { flex: 1; overflow-y: auto; padding: 34px 40px 90px; scroll-behavior: smooth; }
#main > * { max-width: 940px; margin-left: auto; margin-right: auto; }
#menu-btn { display: none; }
#side-mask { display: none; }

/* ---------------- 首页 ---------------- */
.hero {
  padding: 36px 36px 30px;
  background: linear-gradient(135deg, #1d2130 0%, #191c26 60%, #1b1e2a 100%);
  border: 1px solid var(--border); border-radius: 18px;
}
.hero-kicker { font-size: 11px; letter-spacing: 3px; color: var(--accent); font-weight: 700; }
.hero h1 { font-size: 30px; margin: 10px 0 12px; }
.hero-sub { color: var(--muted); font-size: 15px; line-height: 1.9; }
.hero-cta { margin-top: 20px; }
.grad-banner {
  padding: 16px 20px; border-radius: 12px; font-size: 15px;
  background: rgba(240,163,94,.10); border: 1px solid rgba(240,163,94,.35);
}
.stage-sec { margin-top: 36px; }
.stage-title { font-size: 20px; }
.stage-title small { font-size: 13px; font-weight: 400; color: var(--muted2); margin-left: 10px; }
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 14px; margin-top: 14px;
}
.home-card {
  display: block; padding: 18px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
  transition: transform .15s ease, border-color .15s ease;
}
.home-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.home-card-top { display: flex; justify-content: space-between; align-items: center; }
.home-card-order { font-size: 22px; font-weight: 800; color: #303852; }
.home-card h3 { font-size: 16px; margin: 10px 0 6px; }
.home-card p { font-size: 13px; color: var(--muted); line-height: 1.65; }
.home-card-meta { font-size: 12px; color: var(--muted2); margin-top: 12px; }
.chip { font-size: 11px; padding: 3px 10px; border-radius: 99px; background: #262b38; color: var(--muted); }
.chip-done { background: rgba(94,204,143,.15); color: var(--good); }
.chip-doing { background: rgba(240,163,94,.15); color: var(--accent); }
.home-note { margin-top: 36px; }
.home-note h3 { margin-bottom: 8px; }
.home-note p { color: var(--muted); font-size: 14px; }

/* ---------------- 课程页 ---------------- */
.lesson-head { margin-bottom: 6px; }
.stage-badge {
  display: inline-block; font-size: 12px; padding: 4px 12px; border-radius: 99px;
  background: rgba(240,163,94,.12); color: var(--accent); border: 1px solid rgba(240,163,94,.3);
}
.lesson-head h1 { font-size: 26px; margin: 12px 0 6px; }
.lesson-head p { color: var(--muted); font-size: 14.5px; }
.step-dots { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px auto; }
.dot {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--border);
  color: var(--muted); font-size: 13px; text-decoration: none;
  transition: border-color .15s;
}
.dot:hover { border-color: var(--accent); color: var(--text); }
.dot.active { background: var(--accent); border-color: var(--accent); color: var(--dark-ink); font-weight: 700; }
.dot-quiz { border-style: dashed; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 26px 30px; margin-top: 14px;
}
.step-count { font-size: 11px; letter-spacing: 2px; color: var(--muted2); }
.step-title { font-size: 21px; margin: 8px 0 14px; }

/* 课程正文排版 */
.step-body p, .mount-area p { margin: 10px 0; line-height: 1.9; }
.step-body h3 { font-size: 17px; margin: 22px 0 8px; color: var(--accent2); }
.step-body h4 { font-size: 15px; margin: 16px 0 6px; }
.step-body ul, .step-body ol { padding-left: 24px; margin: 10px 0; line-height: 1.9; }
.step-body li { margin: 5px 0; }
.step-body b, .step-body strong { color: #fff; }
.step-body a { color: var(--accent2); }
.step-body table, .mount-area table {
  width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px;
}
.step-body th, .step-body td, .mount-area th, .mount-area td {
  border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top;
}
.step-body th, .mount-area th { background: var(--panel2); font-size: 13px; }
.step-body blockquote {
  border-left: 3px solid var(--accent); padding: 8px 16px; margin: 12px 0;
  background: rgba(240,163,94,.06); border-radius: 0 8px 8px 0; color: var(--muted);
}

.box { padding: 12px 16px; border-radius: 10px; margin: 14px 0; border-left: 3px solid var(--border); font-size: 14px; line-height: 1.8; }
.tip  { background: rgba(111,183,255,.08); border-left-color: var(--accent2); }
.warn { background: rgba(239,111,111,.08); border-left-color: var(--bad); }
.note { background: rgba(240,163,94,.08); border-left-color: var(--accent); }
.term { border-bottom: 1px dotted var(--accent); cursor: help; }
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  background: #262b38; padding: 2px 7px; border-radius: 6px;
  border: 1px solid #333a4c; border-bottom-width: 2px;
}

/* ---------------- 互动组件 ---------------- */
.mount-area { margin-top: 10px; }
.canvas-wrap {
  margin: 16px 0; padding: 14px;
  background: #0b0d13; border: 1px solid var(--border); border-radius: 12px;
}
.canvas-wrap canvas { display: block; width: 100%; height: auto; border-radius: 6px; touch-action: none; }
.demo-caption { font-size: 13px; color: var(--muted); margin: 8px 0; line-height: 1.7; }
.demo-caption.strong { color: var(--text); font-size: 14px; }

.ctl-row { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.ctl-label { width: 132px; flex-shrink: 0; font-size: 13px; color: var(--muted); }
.ctl-value { width: 56px; text-align: right; font-size: 13px; color: var(--accent); font-variant-numeric: tabular-nums; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; flex: 1; height: 6px;
  border-radius: 3px; background: #2a2f3d; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px;
  border-radius: 50%; background: var(--accent); border: 2px solid rgba(255,255,255,.25); cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid rgba(255,255,255,.25); cursor: grab;
}

.seg-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.seg-btn {
  padding: 7px 15px; border-radius: 9px; font-size: 13px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--border); color: var(--muted);
  font-family: inherit; transition: all .15s;
}
.seg-btn:hover { border-color: var(--accent); color: var(--text); }
.seg-btn.active { background: var(--accent); border-color: var(--accent); color: var(--dark-ink); font-weight: 600; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 10px; font-size: 14px; font-family: inherit;
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  text-decoration: none; cursor: pointer; transition: all .15s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #e08b3d);
  border-color: transparent; color: var(--dark-ink); font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-big { padding: 13px 24px; font-size: 15px; }
.nav-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 22px auto 40px; }
.nav-row > div { display: flex; gap: 10px; }

/* ---------------- 测验 ---------------- */
.quiz-q { margin: 22px 0 28px; }
.quiz-q-text { font-size: 15px; font-weight: 600; line-height: 1.7; margin-bottom: 10px; }
.quiz-option {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 11px 14px; border-radius: 10px; margin: 7px 0;
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  font-size: 14px; font-family: inherit; cursor: pointer; line-height: 1.6; transition: all .12s;
}
.quiz-option:hover { border-color: var(--accent); }
.quiz-option.selected { border-color: var(--accent); background: rgba(240,163,94,.09); }
.quiz-option.correct { border-color: var(--good); background: rgba(94,204,143,.13); }
.quiz-option.wrong { border-color: var(--bad); background: rgba(239,111,111,.10); }
.opt-letter {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #262b38; font-size: 12px;
}
.quiz-option.correct .opt-letter { background: var(--good); color: var(--dark-ink); }
.quiz-option.wrong .opt-letter { background: var(--bad); color: #fff; }
.quiz-explain {
  margin: 8px 0 0 34px; padding: 10px 14px; border-radius: 8px;
  background: rgba(111,183,255,.07); font-size: 13px; color: var(--muted); line-height: 1.8;
}
.quiz-result { padding: 14px 18px; border-radius: 10px; margin-top: 20px; font-size: 15px; }
.quiz-result.pass { background: rgba(94,204,143,.12); border: 1px solid rgba(94,204,143,.4); }
.quiz-result.fail { background: rgba(239,111,111,.10); border: 1px solid rgba(239,111,111,.35); color: #f3b0b0; }

.hidden { display: none !important; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 920px) {
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }
  body.side-open #sidebar { transform: none; }
  body.side-open #side-mask {
    display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55);
  }
  #menu-btn {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 12px; left: 12px; z-index: 60;
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--panel); border: 1px solid var(--border); color: var(--text);
    font-size: 18px; cursor: pointer;
  }
  #main { padding: 66px 18px 70px; }
  .card { padding: 20px 18px; }
  .hero { padding: 26px 22px; }
  .grid2 { grid-template-columns: 1fr; }
  .ctl-label { width: 96px; font-size: 12px; }
}

/* ============================================================
   iPad / 触控设备适配（Apple Pencil 友好）
   ============================================================ */
html { -webkit-text-size-adjust: 100%; }
body { overscroll-behavior: none; }
/* iOS Safari 工具栏会吃掉 100vh，用 dvh 修正 */
#app { height: 100vh; height: 100dvh; }
#main {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-top: calc(34px + env(safe-area-inset-top));
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}
#sidebar { padding-top: env(safe-area-inset-top); padding-bottom: calc(20px + env(safe-area-inset-bottom)); }

/* 画布：禁掉长按菜单、选中与浏览器手势，交给课程自己处理 */
canvas {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* 触控设备：放大点击目标，手指与笔尖都好按 */
@media (pointer: coarse) {
  .dot { width: 42px; height: 42px; font-size: 15px; }
  .btn { padding: 12px 20px; font-size: 15px; }
  .seg-btn { padding: 10px 18px; font-size: 14px; }
  .quiz-option { padding: 14px 16px; }
  .side-lesson { padding: 11px 18px; }
  .home-card { padding: 20px; }
  input[type="range"] { height: 10px; }
  input[type="range"]::-webkit-slider-thumb { width: 26px; height: 26px; }
  input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; }
  .ctl-row { margin: 14px 0; }
}

/* 窄屏（含 iPad 分屏 Split View）下的安全区修正 */
@media (max-width: 920px) {
  #main {
    padding-top: calc(66px + env(safe-area-inset-top));
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }
  #menu-btn { top: calc(12px + env(safe-area-inset-top)); }
}

/* 添加到主屏幕后的独立 App 模式 */
@media (display-mode: standalone) {
  body { overscroll-behavior: none; }
}
