/* PyLearn 样式 v3 —— Apple 浅色系
 * 设计基调：#f5f5f7 背景、白色卡片、柔和投影、细发丝边框、
 * Apple 蓝 #0071e3、大圆角、克制的动效。
 * 信息架构不变：阅读页 / 练习页 / 自由练习页 / 速查页 / 进度页。
 */

:root {
  --bg: #faf9f5;
  --surface: #ffffff;
  --surface-2: #f7f5ef;
  --fill: rgba(20, 20, 19, 0.05);
  --fill-strong: rgba(20, 20, 19, 0.09);
  --border: rgba(20, 20, 19, 0.09);
  --border-strong: rgba(20, 20, 19, 0.15);
  --text: #1f1d1a;
  --secondary: #6f6a61;
  --tertiary: #a8a39a;

  --accent: #d97757;
  --accent-hover: #c9663f;
  --accent-soft: rgba(217, 119, 87, 0.11);
  --accent-border: rgba(217, 119, 87, 0.32);

  --success: #34c759;
  --success-text: #1d7a35;
  --success-bg: rgba(52, 199, 89, 0.1);
  --success-border: rgba(52, 199, 89, 0.3);
  --danger: #ff3b30;
  --danger-text: #c7251b;
  --danger-bg: rgba(255, 59, 48, 0.08);
  --danger-border: rgba(255, 59, 48, 0.25);
  --warn: #ff9500;
  --warn-text: #9a5b00;
  --warn-bg: rgba(255, 149, 0, 0.1);
  --warn-border: rgba(255, 149, 0, 0.3);

  --code-bg: #f5f3ec;
  --console-bg: #282c34;
  --console-bg-deep: #21252b;
  --console-border: rgba(255, 255, 255, 0.09);
  --console-text: #d7dae0;

  --radius-s: 10px;
  --radius: 14px;
  --radius-l: 18px;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.05);
  --shadow-pop: 0 2px 6px rgba(0, 0, 0, 0.06), 0 12px 32px rgba(0, 0, 0, 0.1);

  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
          "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  /* Anthropic 风格衬线：英文走 New York/Georgia，中文走宋体类 */
  --serif: "New York", ui-serif, Georgia, "Times New Roman",
           "Songti SC", "STSong", "SimSun", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(217, 119, 87, 0.22); }

#app { display: flex; flex-direction: column; height: 100vh; }

/* 细滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.18); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.3); background-clip: content-box; border: 3px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* 统一的焦点环 */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3.5px rgba(217, 119, 87, 0.32);
  border-radius: var(--radius-s);
}

/* ================ 顶栏 ================ */

#topbar {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 0.6rem 1.4rem;
  background: rgba(250, 249, 245, 0.75);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  z-index: 10;
}

#brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* iOS 分段控件式导航 */
#nav {
  display: flex;
  gap: 2px;
  background: var(--fill);
  border-radius: 999px;
  padding: 2px;
}

#nav a {
  color: var(--secondary);
  text-decoration: none;
  padding: 0.24rem 0.95rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

#nav a:hover { color: var(--text); }

#nav a.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0.5px 1px rgba(0, 0, 0, 0.06);
}

/* 运行时状态胶囊 */
.status-pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--warn-text);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn);
}

.status-pill.ready {
  color: var(--success-text);
  background: var(--success-bg);
  border-color: var(--success-border);
}

.status-pill.ready::before { background: var(--success); }

/* ================ 视图容器 ================ */

#main { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

.view { min-height: 100%; }

/* 带侧栏的视图（阅读页 / 练习页） */
.view.with-toc { display: grid; grid-template-columns: 240px minmax(0, 1fr); }

.toc {
  padding: 1.1rem 0.9rem;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border);
}

.toc-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--tertiary);
  padding: 0 0.6rem 0.55rem;
}

.toc-topic { margin: 0.15rem 0; }

.toc-topic > a {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-s);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.15s ease;
}

.toc-topic > a:hover { background: var(--fill); }

.toc-topic > a.active { background: var(--fill-strong); }

.toc-exercises { padding-left: 0.55rem; margin-bottom: 0.4rem; }

.toc-exercise {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.26rem 0.6rem;
  border-radius: var(--radius-s);
  color: var(--secondary);
  text-decoration: none;
  font-size: 0.87rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.toc-exercise:hover { background: var(--fill); color: var(--text); }

.toc-exercise.active { background: var(--fill-strong); color: var(--text); font-weight: 600; }

.toc-exercise .dot {
  width: 0.42em;
  height: 0.42em;
  border-radius: 50%;
  background: var(--tertiary);
  flex: 0 0 auto;
}

.toc-exercise .dot.done { background: var(--success); }

.toc-exercise .check { font-size: 0.78rem; color: var(--success-text); width: 1em; text-align: center; flex: 0 0 auto; }

/* ================ 阅读页（学习） ================ */

.doc {
  max-width: 780px;
  margin: 0 auto;
  padding: 2.2rem clamp(1rem, 4vw, 2.6rem) 6rem;
}

.doc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.doc-head h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0.2rem 0 0;
}

.topic-progress-chip {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.18rem 0.75rem;
  border-radius: 999px;
  box-shadow: var(--shadow-card);
}

.markdown h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin: 0.2rem 0 1rem; }

/* Anthropic 式排印：标题与阅读正文用衬线，UI 控件保持无衬线 */
.doc-head h1, .markdown h1, .markdown h2, .markdown h3,
.section-title, .task .task-title, .playground h1, .tool-page h1,
.progress-card .p-title, .ex-list-item .ex-name, .wb-head .wb-title {
  font-family: var(--serif);
}

.doc .markdown {
  font-family: var(--serif);
  font-size: 1.03rem;
  line-height: 1.8;
}

.doc .markdown code { font-family: var(--mono); font-size: 0.82em; }
.doc .markdown pre, .doc .markdown pre code { font-family: var(--mono); }
.doc .markdown table { font-family: var(--sans); font-size: 0.92rem; }

/* 每个 topic 的 intro 都以「# 标题」开头，与页头标题重复，隐藏之 */
.doc .markdown > h1:first-child { display: none; }

.markdown h2 {
  font-size: 1.24rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 2.2rem 0 0.7rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.markdown h3 { font-size: 1.05rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }

.markdown p { margin: 0.7rem 0; }

.markdown ul, .markdown ol { padding-left: 1.5rem; }

.markdown li { margin: 0.35rem 0; }

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

.markdown blockquote {
  margin: 0.9rem 0;
  padding: 0.1rem 1rem;
  border-left: 3px solid var(--accent-border);
  color: var(--secondary);
}

.markdown table {
  border-collapse: separate;
  border-spacing: 0;
  margin: 0.9rem 0;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  overflow: hidden;
}

.markdown th, .markdown td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0.45rem 0.7rem;
  font-size: 0.9rem;
}

.markdown tr:last-child td { border-bottom: none; }
.markdown th:last-child, .markdown td:last-child { border-right: none; }

.markdown th { background: var(--surface-2); font-weight: 600; text-align: left; }

.markdown code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--fill);
  padding: 0.12em 0.38em;
  border-radius: 6px;
}

.code-block { position: relative; margin: 0.9rem 0; }

.code-block pre {
  margin: 0;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1.1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.55;
}

.code-block pre code { background: none; padding: 0; font-size: inherit; }

/* 「在编辑器里试试」悬浮按钮 */
.try-btn {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  font-size: 0.76rem;
  font-weight: 500;
  font-family: var(--sans);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.18rem 0.7rem;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: background 0.15s ease, transform 0.15s ease;
}

.try-btn:hover { background: #fff; transform: translateY(-1px); }
.try-btn:active { transform: translateY(0); }

.section-title {
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 2.6rem 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* 语法卡片 */
.syntax-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 1.15rem 1.3rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-card);
}

.syntax-card .sig-row { display: flex; align-items: baseline; gap: 0.7rem; flex-wrap: wrap; }

.syntax-card .sig-name {
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  padding: 0.08rem 0.6rem;
  font-size: 0.84rem;
}

.syntax-card .sig { font-family: var(--mono); font-size: 0.94rem; font-weight: 600; }

.syntax-card .desc { margin: 0.6rem 0 0; }

.syntax-card .notes { margin: 0.6rem 0 0; padding-left: 1.2rem; color: var(--secondary); font-size: 0.88rem; }

.syntax-card .notes li { margin: 0.2rem 0; }

.syntax-card .code-block pre { background: var(--code-bg); }

.syntax-card pre.out-block {
  margin: 0.7rem 0 0;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-s);
  padding: 0.55rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.84rem;
  color: var(--secondary);
  white-space: pre-wrap;
}

/* 速查页的折叠卡片 */
.syntax-card.collapsible { padding: 0; overflow: hidden; }

.syntax-card.collapsible summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.3rem;
  transition: background 0.15s ease;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.5rem;
}

.syntax-card.collapsible summary:hover { background: var(--surface-2); }

.syntax-card.collapsible summary::-webkit-details-marker { display: none; }

.syntax-card.collapsible summary::before {
  content: "›";
  color: var(--tertiary);
  font-weight: 700;
  transition: transform 0.18s ease;
}

.syntax-card.collapsible[open] summary::before { transform: rotate(90deg); }

.syntax-card.collapsible summary .sig-row { flex: 1 1 auto; }

.syntax-card.collapsible summary .desc { flex: 1 0 100%; margin-bottom: 0; }

.syntax-card.collapsible > *:not(summary) { margin-left: 1.3rem; margin-right: 1.3rem; }
.syntax-card.collapsible > *:last-child { margin-bottom: 1.2rem; }

/* 阅读页上的练习列表卡片 */
.ex-list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 0.95rem 1.15rem;
  margin-bottom: 0.8rem;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.ex-list-item:hover { box-shadow: var(--shadow-pop); transform: translateY(-1px); }

.ex-list-item .ex-status {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--fill);
  color: var(--secondary);
  flex: 0 0 auto;
}

.ex-list-item .ex-status.done { background: var(--success-bg); color: var(--success-text); }

.ex-list-item .ex-info { flex: 1 1 auto; min-width: 0; }

.ex-list-item .ex-name { font-weight: 600; font-size: 1rem; }

.ex-list-item .ex-meta { font-size: 0.82rem; color: var(--secondary); margin-top: 0.1rem; }

.ex-list-item .difficulty { color: var(--warn); letter-spacing: 0.08em; }

/* Apple 蓝色主按钮 */
.start-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.88rem;
  font-family: var(--sans);
  border-radius: 999px;
  padding: 0.48rem 1.15rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.1s ease;
}

.start-btn:hover { background: var(--accent-hover); }
.start-btn:active { transform: scale(0.97); }

/* ================ 练习页 ================ */

.practice-main {
  padding: 1.2rem clamp(0.8rem, 2vw, 1.6rem) 3rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  min-width: 0;
}

.practice-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.crumb { color: var(--secondary); font-size: 0.86rem; }

.crumb a { color: var(--secondary); text-decoration: none; }
.crumb a:hover { color: var(--accent); }

.pager { margin-left: auto; display: flex; gap: 0.45rem; }

.pager button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.32rem 0.95rem;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 500;
  font-family: var(--sans);
  color: var(--text);
  box-shadow: var(--shadow-card);
  transition: background 0.15s ease, color 0.15s ease;
}

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

.pager button:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.practice-cols {
  display: grid;
  grid-template-columns: minmax(340px, 5fr) minmax(420px, 6fr);
  gap: 1.1rem;
  align-items: start;
}

/* 题目栏 */
.task {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow-card);
}

.task .task-head { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }

.task .task-title { font-size: 1.28rem; font-weight: 700; letter-spacing: -0.015em; }

.task .difficulty { color: var(--warn); letter-spacing: 0.08em; font-size: 0.88rem; }

.task .ex-passed {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--success-text);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
}

.task .task-body { margin-top: 0.7rem; }

.cases-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0.8rem 0;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  overflow: hidden;
}

.cases-table th, .cases-table td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0.38rem 0.65rem;
  text-align: left;
}

.cases-table tr:last-child td { border-bottom: none; }
.cases-table th:last-child, .cases-table td:last-child { border-right: none; }

.cases-table th { background: var(--surface-2); font-weight: 600; }

.cases-table .io { font-family: var(--mono); font-size: 0.84em; }

.hidden-note { color: var(--secondary); font-size: 0.85rem; margin: 0.4rem 0; }

.task-actions { margin-top: 1rem; display: flex; gap: 0.55rem; flex-wrap: wrap; }

.task-actions button {
  font-size: 0.84rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.34rem 0.95rem;
  cursor: pointer;
  color: var(--text);
  font-family: var(--sans);
  transition: background 0.15s ease, color 0.15s ease;
}

.task-actions button:hover { background: var(--fill); }

.hint-box {
  margin-top: 0.8rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  padding: 0.65rem 0.95rem;
  font-size: 0.92rem;
}

.hint-box .hint-tag { font-weight: 700; color: var(--warn-text); margin-right: 0.4rem; }

/* 工作台栏（编辑器 + 运行 + 输出） */
.workbench {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  position: sticky;
  top: 1.2rem;
}

.wb-head {
  font-size: 0.85rem;
  color: var(--secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.wb-head .wb-title { font-weight: 700; color: var(--text); font-size: 0.95rem; letter-spacing: -0.01em; }

/* 深色面板：编辑器 / 终端，与浅色页面形成层次 */
.editor-shell {
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--console-bg);
  box-shadow: var(--shadow-card);
}

.editor-shell .editor-host { height: clamp(300px, 46vh, 560px); }

.editor-shell .cm-editor { height: 100%; font-size: 0.92rem; }

.editor-shell .cm-scroller { font-family: var(--mono); }

.stdin-box {
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: var(--radius);
  padding: 0.5rem 0.8rem;
  background: var(--console-bg-deep);
  color: #9da5b4;
  font-size: 0.82rem;
}

.stdin-box summary { cursor: pointer; user-select: none; color: #c8ccd4; }

.stdin-box textarea {
  width: 100%;
  margin-top: 0.5rem;
  background: rgba(0, 0, 0, 0.25);
  color: var(--console-text);
  border: 1px solid var(--console-border);
  border-radius: var(--radius-s);
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.5rem;
  resize: vertical;
  box-sizing: border-box;
}

.stdin-box textarea:focus-visible { box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.5); }

.wb-toolbar { display: flex; gap: 0.55rem; flex-wrap: wrap; }

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.46rem 1.15rem;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--sans);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.btn:active:not(:disabled) { transform: scale(0.97); }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-run { background: var(--accent); color: #fff; }
.btn-run:hover:not(:disabled) { background: var(--accent-hover); }

.btn-submit { background: #e8e8ed; color: var(--text); }
.btn-submit:hover:not(:disabled) { background: #dcdce1; }

.btn-ghost { background: transparent; color: var(--secondary); border: 1px solid var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--fill); color: var(--text); }

/* 终端输出面板 */
.output {
  background: var(--console-bg);
  color: var(--console-text);
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 0.85rem 1rem;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow-y: auto;
  min-height: 3.2em;
}

.output::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); background-clip: content-box; border: 3px solid transparent; }

.output .out-score { font-size: 1.3rem; font-weight: 700; color: #30d158; font-family: var(--sans); letter-spacing: -0.01em; }

.output .out-score.fail { color: #ff6961; }

.output .out-case { margin: 0.4rem 0; padding-left: 0.65rem; border-left: 2px solid rgba(255, 255, 255, 0.14); }

.output .out-case.pass { border-left-color: #30d158; }
.output .out-case.fail { border-left-color: #ff6961; }

.output .out-err-title { color: #ff6961; font-family: var(--sans); font-weight: 600; margin-top: 0.4rem; }

.output details { margin-top: 0.3rem; }
.output summary { cursor: pointer; color: #8b93a3; font-family: var(--sans); }
.output details pre { margin: 0.4rem 0 0; color: #b8bdc7; }

/* ================ 自由练习页 ================ */

.playground {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.8rem clamp(1rem, 3vw, 2rem) 4rem;
}

.playground h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 0.2rem 0 0.4rem; }

.playground .pg-note { color: var(--secondary); font-size: 0.9rem; margin-bottom: 1rem; }

.playground .editor-shell .editor-host { height: clamp(340px, 52vh, 620px); }

/* ================ 速查页 / 进度页 ================ */

.tool-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.8rem clamp(1rem, 3vw, 2rem) 4rem;
}

.tool-page h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 0.2rem 0 1rem; }

.ref-toolbar { display: flex; gap: 0.6rem; margin-bottom: 1.1rem; flex-wrap: wrap; }

#ref-search {
  flex: 1 1 220px;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
  font-family: var(--sans);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.15s ease;
}

#ref-search:focus-visible { box-shadow: 0 0 0 3.5px rgba(217, 119, 87, 0.32); }

#ref-search::placeholder { color: var(--tertiary); }

.ref-mode-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 500;
  font-family: var(--sans);
  color: var(--text);
  box-shadow: var(--shadow-card);
  transition: background 0.15s ease, color 0.15s ease;
}

.ref-mode-btn:hover { background: var(--fill); }

.ref-mode-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
  box-shadow: none;
}

.ref-group-title {
  font-weight: 700;
  margin: 1.5rem 0 0.7rem;
  color: var(--secondary);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.ref-empty { color: var(--secondary); text-align: center; padding: 3rem 0; }

.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-card);
}

.progress-card .p-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

.progress-card .p-title { font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em; }

.progress-card .p-count { color: var(--secondary); font-size: 0.86rem; }

.progress-bar {
  height: 6px;
  background: var(--fill);
  border-radius: 999px;
  margin: 0.7rem 0;
  overflow: hidden;
}

.progress-bar > div {
  height: 100%;
  background: linear-gradient(90deg, #e3957a, #d97757);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.ex-row { display: flex; justify-content: space-between; font-size: 0.9rem; padding: 0.22rem 0; color: var(--secondary); }

.ex-row .ex-name { color: var(--text); }

.ex-row .score-pass { color: var(--success-text); font-weight: 600; }

.danger-zone { margin-top: 2.2rem; }

.btn-danger {
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
  border-radius: 999px;
  padding: 0.45rem 1.05rem;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--sans);
  transition: background 0.15s ease;
}

.btn-danger:hover { background: rgba(255, 59, 48, 0.14); }

/* ================ 窄屏 ================ */

@media (max-width: 999px) {
  .view.with-toc { grid-template-columns: 1fr; }
  .toc {
    position: static;
    height: auto;
    max-height: 34vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .practice-cols { grid-template-columns: 1fr; }
  .workbench { position: static; }
  #topbar { flex-wrap: wrap; gap: 0.6rem; padding: 0.55rem 1rem; }
  .status-pill { margin-left: 0; }
}
