/* ScreenMirror Markdown 主题 · 深色磨砂玻璃
   值来自 design/tokens.css（深色）、design/typography.css 与 GlassStyle.swift。
   --s 是字号缩放（对应 Dynamic Type / pt-scale），默认 1。 */

.md-page {
  --bg: #0F141B;
  --text: #F3F4F6;
  --text-2: #9CA3AF;
  --text-3: #6B7280;
  --link: #60A5FA;
  --fill: rgba(255,255,255,.07);
  --edge: rgba(255,255,255,.10);
  --sep: rgba(255,255,255,.07);
  --hl: rgba(255,255,255,.06);
  --green: #34D399; --amber: #FBBF24; --purple: #A78BFA; --teal: #2DD4BF; --orange: #FB923C; --red: #F87171; --blue: #60A5FA;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --math: "STIX Two Math", "Latin Modern Math", "Cambria Math", "Times New Roman", serif;
  background:
    radial-gradient(560px 420px at 0% 0%, rgba(37,99,235,.30), transparent 70%),
    radial-gradient(520px 460px at 100% 100%, rgba(20,184,166,.20), transparent 70%),
    #0F141B;
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* ---------- 磨砂卡（GlassCardView 的 CSS 写法） ---------- */
.glass {
  border: 0.5px solid transparent;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.028)) padding-box,
    linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.04)) border-box;
  box-shadow: 0 10px 30px rgba(0,0,0,.28);
}
.glass-inset {
  border: 0.5px solid transparent;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02)) padding-box,
    linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.03)) border-box;
}
.glass-raised {
  border: 0.5px solid transparent;
  background:
    linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.05)) padding-box,
    linear-gradient(180deg, rgba(255,255,255,.20), rgba(255,255,255,.06)) border-box;
}
.circle-btn {
  width: 44px; height: 44px; border-radius: 22px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text); cursor: pointer; padding: 0; flex-shrink: 0;
}
.icon-btn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--text-2); cursor: pointer; padding: 0; border-radius: 12px;
}
.icon-btn:hover { background: var(--hl); color: var(--text); }

/* ---------- 正文 ---------- */
.md { font-size: calc(17px * var(--s, 1)); line-height: 1.65; color: var(--text); word-break: break-word; }
.md > * { margin: 0; }
.md > * + * { margin-top: calc(16px * var(--s, 1)); }

.md h1 { font-size: calc(28px * var(--s, 1)); line-height: 1.25; font-weight: 700; letter-spacing: .01em; }
.md h2 { font-size: calc(22px * var(--s, 1)); line-height: 1.3; font-weight: 600; }
.md h3 { font-size: calc(20px * var(--s, 1)); line-height: 1.35; font-weight: 600; }
.md h4 { font-size: calc(17px * var(--s, 1)); line-height: 1.4; font-weight: 600; }
.md h5 { font-size: calc(15px * var(--s, 1)); line-height: 1.4; font-weight: 600; }
.md h6 { font-size: calc(13px * var(--s, 1)); line-height: 1.4; font-weight: 600; color: var(--text-2); letter-spacing: .02em; }
.md > * + h2 { margin-top: calc(36px * var(--s, 1)); }
.md > * + h3 { margin-top: calc(28px * var(--s, 1)); }
.md > * + h4, .md > * + h5, .md > * + h6 { margin-top: calc(24px * var(--s, 1)); }
.md > h1 + *, .md > h2 + *, .md > h3 + * { margin-top: calc(10px * var(--s, 1)); }
.md > h4 + *, .md > h5 + *, .md > h6 + * { margin-top: calc(6px * var(--s, 1)); }

.md .meta { font-size: calc(13px * var(--s, 1)); color: var(--text-2); line-height: 1.4; }
.md .lead { color: var(--text-2); }

/* 行内 */
.md strong { font-weight: 600; color: var(--text); }
.md em { font-style: italic; }
.md del { color: var(--text-2); text-decoration-thickness: 1px; }
.md code, .code-inline {
  font-family: var(--mono); font-size: .86em; padding: .12em .42em; border-radius: 6px;
  background: var(--fill); box-shadow: inset 0 0 0 .5px var(--edge); color: var(--text);
}
.md a { color: var(--link); text-decoration: underline; text-decoration-color: rgba(96,165,250,.40); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.md a:hover { text-decoration-color: var(--link); }
.md a.ext::after { content: "↗"; font-size: .78em; margin-left: .15em; }
.md kbd {
  font-family: var(--sans); font-size: .82em; padding: .1em .45em; border-radius: 6px;
  background: rgba(255,255,255,.10); box-shadow: inset 0 -1px 0 rgba(0,0,0,.35), inset 0 0 0 .5px rgba(255,255,255,.16);
}
.math-i { font-family: var(--math); font-style: italic; font-size: 1.08em; letter-spacing: .02em; }

/* 引用：嵌一层的 inset 卡，文字降一级 */
.md blockquote {
  padding: calc(14px * var(--s, 1)) calc(16px * var(--s, 1)); color: var(--text-2);
  border: 0.5px solid transparent; border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02)) padding-box,
    linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.03)) border-box;
}
.md blockquote > * { margin: 0; }
.md blockquote > * + * { margin-top: 10px; }
.md blockquote strong { color: var(--text); }
.md blockquote blockquote { padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.08); }

/* 提示块（扩展语法 > [!TIP] / [!WARNING]，IovisMarkdown 暂未支持） */
.md .callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 16px; color: var(--text); }
.md .callout .ic { width: 22px; height: 22px; flex-shrink: 0; margin-top: 2px; }
.md .callout .ttl { font-weight: 600; font-size: calc(15px * var(--s, 1)); display: block; margin-bottom: 2px; }
.md .callout p { margin: 0; font-size: calc(15px * var(--s, 1)); line-height: 1.6; color: var(--text-2); }

/* 列表 */
.md ul, .md ol { padding-left: calc(24px * var(--s, 1)); }
.md li + li { margin-top: calc(8px * var(--s, 1)); }
.md li > ul, .md li > ol { margin-top: calc(8px * var(--s, 1)); }
.md ul { list-style: none; }
.md ul > li { position: relative; }
.md ul > li::before {
  content: ""; position: absolute; left: calc(-16px * var(--s, 1)); top: calc(.82em - 3px);
  width: 6px; height: 6px; border-radius: 3px; background: var(--text-2);
}
.md ul ul > li::before { background: none; box-shadow: inset 0 0 0 1.25px var(--text-2); }
.md ul ul ul > li::before { width: 6px; height: 1.5px; border-radius: 1px; top: calc(.82em - 1px); background: var(--text-2); box-shadow: none; }
.md ol { list-style: none; counter-reset: n; }
.md ol > li { position: relative; counter-increment: n; }
.md ol > li::before {
  content: counter(n); position: absolute; left: calc(-28px * var(--s, 1)); top: calc(.18em * var(--s, 1));
  width: calc(20px * var(--s, 1)); height: calc(20px * var(--s, 1)); border-radius: 10px;
  font-size: calc(12px * var(--s, 1)); line-height: calc(20px * var(--s, 1)); font-weight: 600; text-align: center;
  font-variant-numeric: tabular-nums; color: var(--text); background: var(--fill); box-shadow: inset 0 0 0 .5px var(--edge);
}
.md ol { padding-left: calc(30px * var(--s, 1)); }
.md ol ol > li::before { background: none; box-shadow: none; color: var(--text-2); content: counter(n) "."; width: auto; left: calc(-20px * var(--s, 1)); }

/* 任务列表 */
.md ul.tasks { padding-left: 0; }
.md ul.tasks > li::before { display: none; }
.md ul.tasks > li { display: flex; gap: 12px; align-items: flex-start; }
.md ul.tasks label { display: flex; gap: 12px; align-items: flex-start; cursor: default; }
.md ul.tasks input {
  appearance: none; -webkit-appearance: none; margin: calc(.2em * var(--s, 1)) 0 0; flex-shrink: 0;
  width: calc(22px * var(--s, 1)); height: calc(22px * var(--s, 1)); border-radius: 7px;
  background: var(--fill); box-shadow: inset 0 0 0 .5px var(--edge);
}
.md ul.tasks .done { color: var(--text-2); }
.md ul.tasks .chk { position: relative; flex-shrink: 0; width: calc(22px * var(--s, 1)); height: calc(22px * var(--s, 1)); margin-top: calc(.2em * var(--s, 1)); }
.md ul.tasks .chk input { position: absolute; inset: 0; margin: 0; }
.md ul.tasks .chk svg { position: absolute; inset: 4px; pointer-events: none; }

/* 分隔线 */
.md hr { border: 0; height: .5px; background: rgba(255,255,255,.12); margin-top: calc(32px * var(--s, 1)); margin-bottom: 0; }
.md hr + * { margin-top: calc(32px * var(--s, 1)); }

/* 图片 */
.md figure { margin-left: 0; margin-right: 0; }
.md figure .img {
  border-radius: 16px; overflow: hidden; box-shadow: inset 0 0 0 .5px rgba(255,255,255,.12), 0 10px 30px rgba(0,0,0,.28);
}
.md figcaption { margin-top: 8px; font-size: calc(13px * var(--s, 1)); line-height: 1.45; color: var(--text-2); text-align: center; }
.placeholder {
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.035) 0 10px, rgba(255,255,255,.015) 10px 20px);
  color: var(--text-2); font-size: 13px;
}

/* 表格：磨砂卡里放表，表头一档灰底 */
.md .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0; }
.md table { border-collapse: collapse; width: 100%; font-size: calc(15px * var(--s, 1)); line-height: 1.45; }
.md th { text-align: left; font-size: calc(13px * var(--s, 1)); font-weight: 600; color: var(--text-2); background: rgba(255,255,255,.04); }
.md th, .md td { padding: calc(11px * var(--s, 1)) calc(14px * var(--s, 1)); vertical-align: top; }
.md tr + tr td, .md thead + tbody tr:first-child td { border-top: .5px solid var(--sep); }
.md td.c, .md th.c { text-align: center; }
.md td.r, .md th.r { text-align: right; font-variant-numeric: tabular-nums; }
.md td.span { background: rgba(255,255,255,.025); border-right: .5px solid var(--sep); vertical-align: middle; font-weight: 600; }
.md th.sep, .md td.sep { border-right: .5px solid var(--sep); }

/* 代码块：inset 卡 + 顶部语言名与拷贝 */
.md .code { padding: 0; overflow: hidden; }
.md .code-bar { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 0 16px; height: 44px; border-bottom: .5px solid var(--sep); }
.md .code-lang { font-family: var(--mono); font-size: 12px; color: var(--text-2); letter-spacing: .02em; }
.md pre { margin: 0; padding: 14px 16px 16px; overflow-x: auto; font-family: var(--mono); font-size: calc(14px * var(--s, 1)); line-height: 1.6; color: var(--text); tab-size: 4; }
.md pre code { background: none; box-shadow: none; padding: 0; font-size: inherit; border-radius: 0; }
.tk-k { color: var(--purple); }
.tk-s { color: var(--green); }
.tk-n { color: var(--amber); }
.tk-c { color: var(--text-2); font-style: italic; }
.tk-f { color: var(--blue); }
.tk-t { color: var(--teal); }
.tk-p { color: var(--orange); }

/* 公式块 */
.md .math { padding: calc(20px * var(--s, 1)) 16px; display: flex; justify-content: center; align-items: center; overflow-x: auto; font-family: var(--math); font-size: calc(20px * var(--s, 1)); color: var(--text); }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 .2em; }
.frac > span { padding: 0 .25em; line-height: 1.25; }
.frac > span:first-child { border-bottom: 1px solid var(--text); padding-bottom: .1em; }
.frac > span:last-child { padding-top: .1em; }
.math .op { margin: 0 .35em; font-style: normal; }
.math .tx { font-family: var(--sans); font-style: normal; font-size: .82em; }

/* 图表（Mermaid） */
.md .diagram { padding: 0; overflow: hidden; }
.seg { display: inline-flex; padding: 2px; border-radius: 9px; background: rgba(118,118,128,.24); }
.seg span { font-size: 13px; font-weight: 500; padding: 4px 12px; border-radius: 7px; color: var(--text); line-height: 18px; }
.seg span.on { background: rgba(255,255,255,.18); box-shadow: 0 1px 3px rgba(0,0,0,.3); font-weight: 600; }
.flow { padding: 20px 16px 22px; display: flex; flex-direction: column; align-items: center; }
.node { font-size: 14px; line-height: 1.35; padding: 10px 16px; border-radius: 12px; background: var(--fill); box-shadow: inset 0 0 0 .5px rgba(255,255,255,.16); color: var(--text); text-align: center; min-width: 150px; box-sizing: border-box; }
.node.round { border-radius: 999px; }
.node.decide { border-radius: 4px; background: rgba(255,255,255,.10); clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 12px 100%, 0 50%); padding: 10px 26px; box-shadow: none; }
.edge { width: 1px; height: 22px; background: rgba(255,255,255,.28); position: relative; }
.edge::after { content: ""; position: absolute; left: -3.5px; bottom: -1px; border: 4px solid transparent; border-top: 5px solid rgba(255,255,255,.45); border-bottom: 0; }
.edge-label { font-size: 12px; color: var(--text-2); font-family: var(--sans); }

/* 规格板 */
.spec-row { display: grid; grid-template-columns: 300px 390px minmax(0, 1fr); gap: 0; border-top: .5px solid rgba(255,255,255,.10); }
.spec-src { padding: 24px 20px; font-family: var(--mono); font-size: 12.5px; line-height: 1.7; color: var(--text-2); white-space: pre-wrap; word-break: break-all; }
.spec-out { padding: 24px 20px; border-left: .5px solid rgba(255,255,255,.08); border-right: .5px solid rgba(255,255,255,.08); }
.spec-note { padding: 24px 20px; font-size: 12.5px; line-height: 1.65; color: var(--text-2); }
.spec-note b { color: var(--text); font-weight: 600; display: block; font-size: 13px; margin-bottom: 6px; }
.spec-note .k { font-family: var(--mono); color: var(--text); font-size: 12px; }
.spec-head { display: grid; grid-template-columns: 300px 390px minmax(0, 1fr); font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: .04em; }
.spec-head > div { padding: 0 20px 12px; }
.spec-title { font-size: 13px; font-weight: 600; color: var(--text); padding: 28px 20px 0; letter-spacing: .02em; }
