/* ============================================================
   文本编辑器 — Material Design 3 样式系统
   ============================================================ */

/* ---------- 颜色令牌：亮色 ---------- */
:root {
  --md-primary: #6750A4;
  --md-on-primary: #FFFFFF;
  --md-primary-container: #EADDFF;
  --md-on-primary-container: #21005D;
  --md-secondary: #625B71;
  --md-secondary-container: #E8DEF8;
  --md-on-secondary-container: #1D192B;
  --md-tertiary: #7D5260;
  --md-tertiary-container: #FFD8E4;
  --md-error: #B3261E;
  --md-on-error: #FFFFFF;
  --md-error-container: #F9DEDC;
  --md-on-error-container: #410E0B;

  --md-surface: #FEF7FF;
  --md-surface-dim: #DED8E1;
  --md-surface-bright: #FEF7FF;
  --md-surface-c-lowest: #FFFFFF;
  --md-surface-c-low: #F7F2FA;
  --md-surface-c: #F3EDF7;
  --md-surface-c-high: #ECE6F0;
  --md-surface-c-highest: #E6E0E9;
  --md-on-surface: #1D1B20;
  --md-on-surface-variant: #49454F;
  --md-outline: #79747E;
  --md-outline-variant: #CAC4D0;
  --md-scrim: rgba(0, 0, 0, .32);

  --md-success: #2E7D32;
  --md-warning: #9A6700;

  --shadow-1: 0 1px 2px rgba(0,0,0,.20), 0 1px 3px 1px rgba(0,0,0,.10);
  --shadow-2: 0 1px 2px rgba(0,0,0,.20), 0 2px 6px 2px rgba(0,0,0,.12);
  --shadow-3: 0 4px 8px 3px rgba(0,0,0,.12), 0 1px 3px rgba(0,0,0,.20);

  --state-hover: .08;
  --state-focus: .10;
  --state-press: .12;

  --font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "PingFang SC",
             "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", Roboto, sans-serif;
  --font-mono: var(--editor-font, "Cascadia Code", "JetBrains Mono", Consolas,
               "SF Mono", Menlo, "Sarasa Mono SC", "Microsoft YaHei Mono", monospace);

  --appbar-h: 56px;
  --tabbar-h: 40px;
  --status-h: 26px;
  --radius-xs: 4px;
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 16px;
  --radius-xl: 28px;
  --ease-emph: cubic-bezier(.2, 0, 0, 1);
  --ease-std: cubic-bezier(.2, 0, 0, 1);
  --dur-s: 120ms;
  --dur-m: 220ms;
  --dur-l: 380ms;

  color-scheme: light;
}

/* ---------- 颜色令牌：暗色 ---------- */
:root[data-theme="dark"] {
  --md-primary: #D0BCFF;
  --md-on-primary: #381E72;
  --md-primary-container: #4F378B;
  --md-on-primary-container: #EADDFF;
  --md-secondary: #CCC2DC;
  --md-secondary-container: #4A4458;
  --md-on-secondary-container: #E8DEF8;
  --md-tertiary: #EFB8C8;
  --md-tertiary-container: #633B48;
  --md-error: #F2B8B5;
  --md-on-error: #601410;
  --md-error-container: #8C1D18;
  --md-on-error-container: #F9DEDC;

  --md-surface: #141218;
  --md-surface-dim: #141218;
  --md-surface-bright: #3B383E;
  --md-surface-c-lowest: #0F0D13;
  --md-surface-c-low: #1D1B20;
  --md-surface-c: #211F26;
  --md-surface-c-high: #2B2930;
  --md-surface-c-highest: #36343B;
  --md-on-surface: #E6E0E9;
  --md-on-surface-variant: #CAC4D0;
  --md-outline: #938F99;
  --md-outline-variant: #49454F;
  --md-scrim: rgba(0, 0, 0, .60);

  --md-success: #7BD389;
  --md-warning: #E9C46A;

  --shadow-1: 0 1px 3px rgba(0,0,0,.45);
  --shadow-2: 0 2px 8px rgba(0,0,0,.55);
  --shadow-3: 0 8px 24px rgba(0,0,0,.6);

  color-scheme: dark;
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--md-on-surface);
  background: var(--md-surface);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

::selection { background: color-mix(in srgb, var(--md-primary) 30%, transparent); }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--md-outline-variant) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--md-outline-variant); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--md-outline); background-clip: content-box; }

/* ---------- 启动遮罩 ---------- */
.splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: var(--md-surface);
  transition: opacity var(--dur-l) var(--ease-emph), visibility var(--dur-l);
}
.splash.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; width: min(320px, 80vw); }
.splash-logo { width: 88px; height: 88px; animation: floaty 2.4s var(--ease-std) infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.splash-title { font-size: 22px; font-weight: 500; letter-spacing: .2px; }
.splash-status { font-size: 13px; color: var(--md-on-surface-variant); min-height: 19px; text-align: center; }
.splash-source { font-size: 11px; color: var(--md-outline); font-family: var(--font-mono); word-break: break-all; text-align: center; min-height: 16px; }

.linear-progress { width: 100%; height: 4px; border-radius: 2px; background: var(--md-secondary-container); overflow: hidden; position: relative; }
.linear-progress-bar { position: absolute; inset: 0; background: var(--md-primary); border-radius: 2px; transform-origin: left; animation: indeterminate 1.6s var(--ease-std) infinite; }
@keyframes indeterminate {
  0%   { transform: translateX(-100%) scaleX(.45); }
  50%  { transform: translateX(20%)  scaleX(.65); }
  100% { transform: translateX(110%) scaleX(.35); }
}

/* ---------- 应用布局 ---------- */
.app {
  height: 100%;
  display: grid;
  grid-template-rows: var(--appbar-h) auto 1fr var(--status-h);
  background: var(--md-surface);
}
.app[hidden] { display: none; }

/* ---------- 顶部应用栏 ---------- */
.appbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  background: var(--md-surface-c);
  border-bottom: 1px solid var(--md-outline-variant);
  user-select: none;
  -webkit-app-region: drag;
}
.appbar-lead { display: flex; align-items: center; gap: 6px; min-width: 0; }
.appbar-brand { display: flex; align-items: center; gap: 8px; padding-left: 2px; min-width: 0; }
.brand-mark { width: 24px; height: 24px; stroke: none; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: .1px; white-space: nowrap; }
.appbar-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; -webkit-app-region: no-drag; }
.appbar-divider { width: 1px; height: 22px; background: var(--md-outline-variant); margin: 0 5px; }

/* ---------- 图标按钮 ---------- */
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 0; padding: 0; margin: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--md-on-surface-variant);
  cursor: pointer;
  overflow: hidden;
  -webkit-app-region: no-drag;
  transition: color var(--dur-s) var(--ease-std), background var(--dur-s) var(--ease-std);
}
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small svg { width: 17px; height: 17px; }
.icon-btn::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: currentColor; opacity: 0;
  transition: opacity var(--dur-s) var(--ease-std);
}
.icon-btn:hover::before { opacity: var(--state-hover); }
.icon-btn:active::before { opacity: var(--state-press); }
.icon-btn:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 1px; }
.icon-btn[disabled] { opacity: .38; pointer-events: none; }
.icon-btn.active, .icon-btn.toggle.on { color: var(--md-on-primary-container); background: var(--md-primary-container); }

/* 主题图标切换 */
.ic-dark { display: none; }
:root[data-theme="dark"] .ic-light { display: none; }
:root[data-theme="dark"] .ic-dark { display: block; }

/* 保存态指示 */
#btnSave.dirty { color: var(--md-primary); }
#btnSave.dirty::after {
  content: ""; position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--md-primary);
  box-shadow: 0 0 0 2px var(--md-surface-c);
}

/* ---------- 标签栏 ---------- */
.tabbar {
  display: flex;
  align-items: stretch;
  height: var(--tabbar-h);
  background: var(--md-surface-c-low);
  border-bottom: 1px solid var(--md-outline-variant);
  user-select: none;
}
.tabs { display: flex; align-items: stretch; overflow-x: auto; overflow-y: hidden; flex: 1; scrollbar-width: none; }
.tabs::-webkit-scrollbar { height: 0; }
.tab-add { align-self: center; margin: 0 4px; }

.tab {
  position: relative;
  display: flex; align-items: center; gap: 7px;
  padding: 0 8px 0 12px;
  max-width: 220px; min-width: 110px;
  border: 0; border-right: 1px solid var(--md-outline-variant);
  background: transparent;
  color: var(--md-on-surface-variant);
  font: inherit; font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-s) var(--ease-std), color var(--dur-s) var(--ease-std);
}
.tab:hover { background: color-mix(in srgb, var(--md-on-surface) 6%, transparent); }
.tab.active { background: var(--md-surface); color: var(--md-on-surface); font-weight: 500; }
.tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--md-primary); border-radius: 2px 2px 0 0;
}
.tab-icon { width: 15px; height: 15px; flex: none; opacity: .85; }
.tab-name { overflow: hidden; text-overflow: ellipsis; flex: 1; text-align: left; }
.tab-close {
  display: grid; place-items: center;
  width: 20px; height: 20px; flex: none;
  border: 0; border-radius: 50%; padding: 0;
  background: transparent; color: inherit; cursor: pointer;
  opacity: 0; transition: opacity var(--dur-s), background var(--dur-s);
}
.tab-close svg { width: 13px; height: 13px; stroke-width: 2.2; }
.tab:hover .tab-close, .tab.active .tab-close, .tab.dirty .tab-close { opacity: .75; }
.tab-close:hover { background: color-mix(in srgb, var(--md-on-surface) 14%, transparent); opacity: 1; }
.tab.dirty .tab-close svg { display: none; }
.tab.dirty .tab-close::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--md-primary);
}
.tab.dirty:hover .tab-close svg { display: block; }
.tab.dirty:hover .tab-close::before { display: none; }

/* ---------- 工作区 ---------- */
.workarea { display: flex; min-height: 0; background: var(--md-surface); position: relative; }
.pane { position: relative; min-width: 0; display: flex; flex-direction: column; }
.pane-editor { flex: 1 1 60%; }
.pane-preview { flex: 1 1 40%; background: var(--md-surface-c-lowest); border-left: 1px solid var(--md-outline-variant); }
.pane-preview[hidden] { display: none; }
.monaco-host { position: absolute; inset: 0; }

.splitter { width: 6px; cursor: col-resize; background: transparent; position: relative; flex: none; z-index: 5; }
.splitter[hidden] { display: none; }
.splitter::after { content: ""; position: absolute; inset: 0 2px; background: var(--md-outline-variant); transition: background var(--dur-s); }
.splitter:hover::after, .splitter.dragging::after { background: var(--md-primary); }

.drop-hint {
  position: absolute; inset: 12px; z-index: 20;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  border: 2px dashed var(--md-primary);
  border-radius: var(--radius-l);
  background: color-mix(in srgb, var(--md-primary) 10%, var(--md-surface));
  color: var(--md-primary);
  font-size: 15px; font-weight: 500;
  backdrop-filter: blur(2px);
}
.drop-hint svg { width: 40px; height: 40px; stroke-width: 1.6; }
body.dragging .drop-hint { display: flex; }

/* ---------- 预览面板 ---------- */
.preview-bar {
  display: flex; align-items: center; gap: 4px;
  height: 36px; flex: none;
  padding: 0 6px 0 14px;
  background: var(--md-surface-c-low);
  border-bottom: 1px solid var(--md-outline-variant);
  font-size: 12px; color: var(--md-on-surface-variant);
  user-select: none;
}
.preview-title { font-weight: 600; letter-spacing: .3px; text-transform: uppercase; font-size: 11px; }
.spacer { flex: 1; }

.markdown-body {
  flex: 1; overflow: auto; padding: 24px 32px 64px;
  font-size: 15px; line-height: 1.75;
  color: var(--md-on-surface);
  word-wrap: break-word;
}
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin: 1.6em 0 .6em; line-height: 1.3; font-weight: 600;
}
.markdown-body h1 { font-size: 1.9em; padding-bottom: .3em; border-bottom: 1px solid var(--md-outline-variant); }
.markdown-body h2 { font-size: 1.5em; padding-bottom: .25em; border-bottom: 1px solid var(--md-outline-variant); }
.markdown-body h3 { font-size: 1.25em; }
.markdown-body h4 { font-size: 1.08em; }
.markdown-body h5, .markdown-body h6 { font-size: 1em; color: var(--md-on-surface-variant); }
.markdown-body p { margin: 0 0 1em; }
.markdown-body a { color: var(--md-primary); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body ul, .markdown-body ol { margin: 0 0 1em; padding-left: 1.7em; }
.markdown-body li { margin: .25em 0; }
.markdown-body li > input[type="checkbox"] { margin-right: .5em; accent-color: var(--md-primary); }
.markdown-body blockquote {
  margin: 0 0 1em; padding: .4em 1em;
  border-left: 4px solid var(--md-primary);
  background: var(--md-surface-c-low);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  color: var(--md-on-surface-variant);
}
.markdown-body blockquote > *:last-child { margin-bottom: 0; }
.markdown-body code {
  font-family: var(--font-mono); font-size: .875em;
  background: var(--md-surface-c-high);
  padding: .18em .42em; border-radius: var(--radius-xs);
}
.markdown-body pre {
  margin: 0 0 1em; padding: 14px 16px;
  background: var(--md-surface-c-low);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--radius-m);
  overflow: auto; line-height: 1.55;
}
.markdown-body pre code { background: none; padding: 0; font-size: 13px; white-space: pre; }
.markdown-body table { border-collapse: collapse; margin: 0 0 1em; display: block; overflow: auto; max-width: 100%; }
.markdown-body th, .markdown-body td { border: 1px solid var(--md-outline-variant); padding: 7px 13px; }
.markdown-body th { background: var(--md-surface-c); font-weight: 600; }
.markdown-body tr:nth-child(2n) td { background: var(--md-surface-c-low); }
.markdown-body hr { border: 0; border-top: 1px solid var(--md-outline-variant); margin: 2em 0; }
.markdown-body img { max-width: 100%; border-radius: var(--radius-s); }
.markdown-body kbd {
  font-family: var(--font-mono); font-size: .82em; padding: .15em .45em;
  border: 1px solid var(--md-outline-variant); border-bottom-width: 2px;
  border-radius: var(--radius-xs); background: var(--md-surface-c);
}
.markdown-body .task-list-item { list-style: none; margin-left: -1.3em; }
.markdown-body .md-empty { color: var(--md-outline); text-align: center; padding: 48px 0; font-style: italic; }
.markdown-body .mermaid-raw { color: var(--md-on-surface-variant); }

/* HTML 预览（沙箱 iframe） */
.preview-frame {
  flex: 1; min-height: 0; width: 100%;
  border: 0; background: #ffffff; color-scheme: light;
}
.preview-frame[hidden] { display: none; }

/* ---------- 状态栏 ---------- */
.statusbar {
  display: flex; align-items: center; gap: 0;
  padding: 0 4px;
  background: var(--md-surface-c);
  border-top: 1px solid var(--md-outline-variant);
  font-size: 12px; color: var(--md-on-surface-variant);
  user-select: none; overflow: hidden;
}
.status-flex { flex: 1; }
.status-item {
  display: inline-flex; align-items: center; gap: 5px;
  height: 100%; padding: 0 9px;
  border: 0; background: transparent; color: inherit;
  font: inherit; cursor: pointer; white-space: nowrap;
  border-radius: var(--radius-xs);
  transition: background var(--dur-s) var(--ease-std);
}
.status-item:hover { background: color-mix(in srgb, var(--md-on-surface) 9%, transparent); }
.status-item svg { width: 13px; height: 13px; }
.status-item[hidden] { display: none; }
#stFile { max-width: 46vw; overflow: hidden; }
#stFileText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stFile.dirty #stFileText::after { content: " ●"; color: var(--md-primary); }
#stCdn { color: var(--md-outline); font-size: 11px; }
#stCdn.warn { color: var(--md-warning); }
#stCdn.err { color: var(--md-error); }

/* ---------- 菜单 ---------- */
.menu {
  position: fixed; z-index: 500;
  min-width: 250px; max-width: 340px;
  padding: 8px 0;
  background: var(--md-surface-c-high);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-2);
  transform-origin: top right;
  animation: menuIn var(--dur-m) var(--ease-emph);
  max-height: 84vh; overflow-y: auto;
}
.menu[hidden] { display: none; }
@keyframes menuIn { from { opacity: 0; transform: scale(.9) translateY(-6px); } to { opacity: 1; transform: none; } }
.menu-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 0 14px; height: 44px;
  border: 0; background: transparent; color: var(--md-on-surface);
  font: inherit; font-size: 14px; text-align: left; cursor: pointer; overflow: hidden;
}
.menu-item svg { width: 18px; height: 18px; color: var(--md-on-surface-variant); }
.menu-item span:not(.mi-check) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item kbd {
  font-family: var(--font-mono); font-size: 11px; color: var(--md-outline);
  background: transparent; letter-spacing: .3px;
}
.menu-item::before { content: ""; position: absolute; inset: 0; background: var(--md-on-surface); opacity: 0; transition: opacity var(--dur-s); }
.menu-item:hover::before { opacity: var(--state-hover); }
.menu-item:active::before { opacity: var(--state-press); }
.menu-item[disabled] { opacity: .38; pointer-events: none; }
.menu-sep { height: 1px; background: var(--md-outline-variant); margin: 8px 0; }
.mi-check { width: 18px; height: 18px; flex: none; display: grid; place-items: center; }
.menu-item.checked .mi-check::before {
  content: ""; width: 12px; height: 7px; border: 2px solid var(--md-primary);
  border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -2px);
}

/* ---------- 对话框 ---------- */
.dialog {
  border: 0; padding: 0;
  border-radius: var(--radius-xl);
  background: var(--md-surface-c-high);
  color: var(--md-on-surface);
  box-shadow: var(--shadow-3);
  max-width: min(560px, 92vw);
  width: 100%;
  max-height: 88vh;
  overflow: hidden;
}
.dialog::backdrop { background: var(--md-scrim); backdrop-filter: blur(2px); }
.dialog[open] { animation: dlgIn var(--dur-m) var(--ease-emph); }
@keyframes dlgIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
.dialog-form { display: flex; flex-direction: column; max-height: 88vh; }
.dialog-title { margin: 0; padding: 24px 24px 0; font-size: 22px; font-weight: 400; line-height: 1.35; }
.dialog-body { padding: 16px 24px 8px; overflow-y: auto; flex: 1; }
.dialog-desc { margin: 0 0 14px; font-size: 14px; color: var(--md-on-surface-variant); line-height: 1.5; white-space: pre-line; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px 24px; flex: none; }

/* 按钮 */
.btn {
  height: 40px; padding: 0 24px;
  border: 0; border-radius: 20px;
  font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; position: relative; overflow: hidden;
  transition: box-shadow var(--dur-s), background var(--dur-s);
}
.btn::before { content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0; transition: opacity var(--dur-s); }
.btn:hover::before { opacity: var(--state-hover); }
.btn:active::before { opacity: var(--state-press); }
.btn.filled { background: var(--md-primary); color: var(--md-on-primary); }
.btn.filled:hover { box-shadow: var(--shadow-1); }
.btn.tonal { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.btn.text { background: transparent; color: var(--md-primary); padding: 0 14px; }
.btn.danger { background: var(--md-error); color: var(--md-on-error); }
.btn:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 2px; }

/* 编码选择 */
.encoding-search {
  display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 14px; margin-bottom: 14px;
  background: var(--md-surface-c-highest);
  border-radius: var(--radius-l);
  color: var(--md-on-surface-variant);
}
.encoding-search svg { width: 18px; height: 18px; }
.encoding-search input {
  flex: 1; border: 0; background: transparent; outline: none;
  font: inherit; font-size: 14px; color: var(--md-on-surface);
}
.chip-list {
  display: flex; flex-wrap: wrap; gap: 8px;
  max-height: 300px; overflow-y: auto; padding: 2px;
  margin-bottom: 8px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--md-outline); border-radius: var(--radius-s);
  background: transparent; color: var(--md-on-surface-variant);
  font: inherit; font-size: 13px; cursor: pointer;
  transition: background var(--dur-s), border-color var(--dur-s), color var(--dur-s);
}
.chip:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); }
.chip.selected {
  background: var(--md-secondary-container); color: var(--md-on-secondary-container);
  border-color: transparent; font-weight: 500;
}
.chip.selected::before {
  content: ""; width: 12px; height: 7px; border: 2px solid currentColor;
  border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -2px);
}
.chip .chip-hint { font-size: 11px; opacity: .7; }
.chip-group-label {
  width: 100%; font-size: 11px; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase; color: var(--md-outline); margin: 8px 0 -2px;
}
.chip-group-label:first-child { margin-top: 0; }

/* 开关 */
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 48px; padding: 4px 2px; cursor: pointer;
}
.switch-label { font-size: 14px; }
.switch-label small {
  display: block; margin-top: 2px;
  font-size: 12px; line-height: 1.4;
  color: var(--md-on-surface-variant);
}
.switch { position: relative; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  display: block; width: 52px; height: 32px;
  border: 2px solid var(--md-outline); border-radius: 16px;
  background: var(--md-surface-c-highest);
  transition: background var(--dur-m) var(--ease-emph), border-color var(--dur-m) var(--ease-emph);
}
.switch-thumb {
  display: block; width: 16px; height: 16px; margin: 6px;
  border-radius: 50%; background: var(--md-outline);
  transition: transform var(--dur-m) var(--ease-emph), width var(--dur-s), height var(--dur-s), margin var(--dur-s), background var(--dur-m);
}
.switch input:checked + .switch-track { background: var(--md-primary); border-color: var(--md-primary); }
.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(20px); width: 24px; height: 24px; margin: 2px;
  background: var(--md-on-primary);
}
.switch input:focus-visible + .switch-track { outline: 2px solid var(--md-primary); outline-offset: 2px; }

/* 设置项 */
.settings-body { max-height: 60vh; }
.setting-group-title {
  font-size: 12px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: var(--md-primary); margin: 20px 0 6px;
}
.setting-group-title:first-child { margin-top: 0; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; padding: 4px 2px; }
.setting-row.column { flex-direction: column; align-items: stretch; gap: 8px; }
.setting-label { font-size: 14px; }
.setting-label em { font-style: normal; font-weight: 600; color: var(--md-primary); }

.segmented { display: inline-flex; border-radius: 20px; overflow: hidden; border: 1px solid var(--md-outline); flex: none; }
.segmented button {
  height: 36px; padding: 0 16px; min-width: 56px;
  border: 0; border-right: 1px solid var(--md-outline);
  background: transparent; color: var(--md-on-surface);
  font: inherit; font-size: 13px; cursor: pointer;
  transition: background var(--dur-s), color var(--dur-s);
}
.segmented button:last-child { border-right: 0; }
.segmented button:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); }
.segmented button.on { background: var(--md-secondary-container); color: var(--md-on-secondary-container); font-weight: 600; }

.slider { flex: 1; max-width: 220px; accent-color: var(--md-primary); height: 4px; }
.text-field {
  height: 40px; padding: 0 14px; min-width: 180px; max-width: 260px;
  border: 1px solid var(--md-outline); border-radius: var(--radius-xs);
  background: transparent; color: var(--md-on-surface);
  font: inherit; font-size: 13px; outline: none;
}
.text-field:focus { border-color: var(--md-primary); border-width: 2px; padding: 0 13px; }
select.text-field { cursor: pointer; }

.mono-box {
  display: block; font-family: var(--font-mono); font-size: 11.5px;
  padding: 10px 12px; border-radius: var(--radius-s);
  background: var(--md-surface-c-lowest); color: var(--md-on-surface-variant);
  word-break: break-all; border: 1px solid var(--md-outline-variant);
}
.cdn-list { display: flex; flex-direction: column; gap: 6px; }
.cdn-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-s);
  background: var(--md-surface-c-lowest);
  border: 1px solid var(--md-outline-variant);
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--md-on-surface-variant); word-break: break-all;
}
.cdn-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--md-outline-variant); flex: none; }
.cdn-item.active { border-color: var(--md-primary); color: var(--md-on-surface); }
.cdn-item.active .dot { background: var(--md-success); }
.cdn-item.failed .dot { background: var(--md-error); }
.cdn-item.failed { opacity: .6; text-decoration: line-through; }

.about-list { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.about-list li { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--md-outline-variant); }
.about-list li:last-child { border-bottom: 0; }
.about-list b { font-weight: 500; color: var(--md-on-surface-variant); }
.about-list span { font-family: var(--font-mono); font-size: 12px; text-align: right; word-break: break-all; }

/* ---------- Snackbar ---------- */
.snackbar {
  position: fixed; left: 50%; bottom: 42px; transform: translateX(-50%) translateY(20px);
  z-index: 900;
  display: flex; align-items: center; gap: 12px;
  min-height: 48px; padding: 10px 16px;
  max-width: min(560px, 92vw);
  background: var(--md-surface-c-highest);
  color: var(--md-on-surface);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-3);
  font-size: 14px;
  opacity: 0;
  transition: opacity var(--dur-m) var(--ease-emph), transform var(--dur-m) var(--ease-emph);
}
.snackbar[hidden] { display: none; }
.snackbar.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.snackbar.error { background: var(--md-error-container); color: var(--md-on-error-container); }
.snackbar.success { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.snack-action {
  border: 0; background: transparent; color: var(--md-primary);
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  padding: 6px 10px; border-radius: var(--radius-xs); flex: none;
}
.snack-action:hover { background: color-mix(in srgb, var(--md-primary) 12%, transparent); }
.snack-action[hidden] { display: none; }

/* ---------- 空态 ---------- */
.empty-state {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--md-outline); background: var(--md-surface);
  user-select: none; pointer-events: none;
}
.empty-state svg { width: 64px; height: 64px; stroke-width: 1.1; opacity: .5; }
.empty-state .es-title { font-size: 17px; color: var(--md-on-surface-variant); }
.empty-state .es-sub { font-size: 13px; }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .brand-name { display: none; }
  .appbar-divider { margin: 0 2px; }
  #stIndent, #stEol, #stCdn { display: none; }
  .workarea { flex-direction: column; }
  .pane-preview { border-left: 0; border-top: 1px solid var(--md-outline-variant); }
  .splitter { width: auto; height: 6px; cursor: row-resize; }
  .splitter::after { inset: 2px 0; }
  .markdown-body { padding: 16px 18px 48px; }
}
@media (max-width: 520px) {
  #btnNew, #btnDownload { display: none; }
  .dialog-title { font-size: 20px; padding: 20px 20px 0; }
  .dialog-body { padding: 12px 20px 4px; }
  .dialog-actions { padding: 12px 20px 20px; }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
