:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #e2e7ef;
  --line2: #edf0f5;
  --fg: #202b3d;
  --fg2: #59677d;
  --fg3: #6e7b8f;
  --brand: #315ee7;
  --brand-d: #254bc3;
  --brand-soft: #eef3ff;
  --accent-ink: #8a5100;
  --accent-soft: #fff7e8;
  --accent-line: #f3d7a4;
  --radius: 14px;
  --shadow: 0 3px 16px rgb(32 43 61 / 3%);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; color: var(--fg); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button, input, select { -webkit-tap-highlight-color: transparent; }
button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); border-radius: 9px; padding: 0 15px; background: var(--panel); color: var(--fg2); font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background .16s, border-color .16s, box-shadow .16s; }
button:hover { background: #f7f9fd; border-color: #c9d3e3; color: var(--fg); }
button:active { background: var(--brand-soft); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #8baaff; outline-offset: 3px; }
button.primary { color: #fff; background: var(--brand); border-color: var(--brand); box-shadow: 0 3px 8px rgb(49 94 231 / 15%); }
button.primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
button:disabled { cursor: wait; opacity: .6; }
button.ghost { background: transparent; border-color: transparent; padding-inline: 10px; }
button.ghost:hover { background: var(--brand-soft); color: var(--brand); }
button.link { color: var(--brand); background: transparent; border-color: transparent; padding-inline: 4px; font-weight: 500; }
select, input[type="text"], input[type="number"] { min-width: 0; width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--fg); background: var(--panel); font-size: 13px; }
select:hover, input[type="text"]:hover, input[type="number"]:hover { border-color: #bfcce0; }
input:disabled { background: var(--bg); color: var(--fg3); cursor: not-allowed; }
input[type="range"] { min-width: 0; flex: 1; width: 100%; min-height: 28px; margin: 0; accent-color: var(--brand); cursor: pointer; }
input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); flex: 0 0 auto; }
.app { height: 100vh; height: 100dvh; min-height: 360px; display: flex; flex-direction: column; }
.topbar { flex: 0 0 auto; height: 80px; padding: 14px 24px; display: flex; align-items: center; gap: 24px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 11px; flex: 0 0 auto; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--brand); color: white; font-size: 25px; font-weight: 750; letter-spacing: -2px; padding-right: 2px; }
.brand-name { font-weight: 750; font-size: 19px; line-height: 1.2; letter-spacing: -.6px; }
.brand-description { margin: 4px 0 0; font-size: 12px; color: var(--fg3); }
.local-badge { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--fg2); padding: 7px 10px; background: #f4f8f6; border-radius: 7px; }
.local-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #28926a; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.workspace { flex: 1; min-height: 0; width: 100%; max-width: 1920px; margin-inline: auto; padding: 20px 24px; display: grid; grid-template-columns: minmax(300px, .9fr) minmax(360px, 1.35fr) 264px; gap: 18px; }
.pane, .settings-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.settings-panel { line-height: 1.3; }
.pane-head { min-height: 76px; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line2); }
.pane-head h2, .settings-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.2px; }
.pane-head p, .settings-head p { margin: 5px 0 0; font-size: 12px; line-height: 1.5; color: var(--fg3); }
.pane-actions { display: flex; gap: 2px; align-items: center; }
.editor-tools { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line2); flex: 0 0 auto; }
.editor-tools label { font-size: 12px; color: var(--fg2); white-space: nowrap; }
.editor-tools select { width: 126px; min-height: 44px; padding-block: 6px; background: #f9faff; }
.tag { font-size: 12px; color: var(--fg3); font-weight: 400; }
.editor-tools .tag { margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mode-hint { font-size: 12px; color: var(--accent-ink); padding: 5px 9px; border-radius: 7px; background: var(--accent-soft); }
.editor-hint { margin: 0; padding: 0 18px 9px; font-size: 12px; color: var(--fg3); }
#src { flex: 1; min-height: 0; width: 100%; resize: none; border: 0; outline-offset: -4px; padding: 19px 20px; font-family: "Cascadia Code", Consolas, "Microsoft YaHei", monospace; font-size: 14px; line-height: 1.85; color: var(--fg); background: var(--panel); tab-size: 2; }
#src::placeholder { color: #7d899c; }
.editor-footer { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 12px 4px 18px; border-top: 1px solid var(--line2); }
.clean-wrap { position: relative; display: flex; align-items: center; gap: 6px; min-width: 0; }
.switch { display: flex; align-items: center; gap: 9px; min-height: 44px; font-size: 13px; color: var(--fg2); cursor: pointer; }
.clean-wrap .switch { gap: 7px; font-size: 12px; }
.clean-wrap.on .switch { color: var(--accent-ink); }
.badge { font-size: 11px; font-weight: 650; color: var(--accent-ink); background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 5px; padding: 1px 5px; font-variant-numeric: tabular-nums; }
.bubble { display: none; position: absolute; bottom: calc(100% + 12px); left: 0; width: min(338px, calc(100vw - 56px)); z-index: 20; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 32px rgb(32 43 61 / 16%); font-size: 12px; line-height: 1.8; color: var(--fg2); }
.bubble.show { display: block; }
.bubble h3 { margin: 0 0 9px; font-size: 14px; color: var(--fg); }
.bubble .rule { margin-top: 5px; }
.bubble .hint { margin-top: 10px; color: var(--fg3); }
.bubble .acts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; }
.bubble .acts button { font-size: 12px; padding-inline: 8px; }
.bubble code { padding: 1px 4px; background: var(--bg); border-radius: 4px; }
.bubble .stat { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.cmp { display: none; border-top: 1px solid var(--line); background: #fafbfd; flex: 0 0 auto; max-height: 36%; }
.cmp.show { display: flex; flex-direction: column; }
.cmp-head { display: flex; align-items: center; gap: 8px; padding: 4px 12px; font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--line2); }
.cmp-head .tag { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-body { display: flex; overflow: auto; min-height: 0; }
.cmp-col { flex: 1; min-width: 0; border-right: 1px solid var(--line2); }
.cmp-col:last-child { border: 0; }
.cmp-col h4 { margin: 0; padding: 7px 12px; font-size: 12px; color: var(--fg3); font-weight: 500; }
.cmp-col.after h4 { color: var(--accent-ink); }
.cmp-col pre { margin: 0; padding: 7px 12px 12px; font-family: Consolas, monospace; font-size: 12px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.pane-r { background: #eaf0f6; }
.pane-r .pane-head { background: var(--panel); border-radius: var(--radius) var(--radius) 0 0; }
.preview-wrap { flex: 1; min-height: 0; display: flex; align-items: flex-start; overflow: auto; padding: 24px; background-image: radial-gradient(#d4ddea .8px, transparent .8px); background-size: 12px 12px; }
#preview-host { position: relative; flex: 0 0 auto; margin-inline: auto; width: 0; height: 0; overflow: hidden; box-shadow: 0 5px 20px rgb(32 43 61 / 10%); }
#preview-frame { position: absolute; top: 0; left: 0; display: block; border: 0; background: transparent; transform-origin: top left; }
.preview-footer { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; padding: 8px 18px; border-top: 1px solid #dce4ee; background: #f8faff; border-radius: 0 0 var(--radius) var(--radius); font-size: 12px; color: var(--fg2); }
.preview-footer .theme-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 35%; }
.zoom-control { display: flex; align-items: center; gap: 9px; min-width: 0; width: 225px; }
.zoom-control label { flex: 0 0 auto; }
.zoom-control b { min-width: 38px; color: var(--fg); font-weight: 550; font-variant-numeric: tabular-nums; }
.empty { max-width: 290px; margin: 60px auto; padding: 28px 18px; text-align: center; color: var(--fg2); background: rgb(255 255 255 / 85%); border: 1px dashed #c5d1e1; border-radius: 12px; }
.empty h3 { margin: 0; font-size: 16px; color: var(--fg); }
.empty p { margin: 10px 0 18px; font-size: 13px; line-height: 1.8; }
.settings-head { display: flex; align-items: center; gap: 6px; justify-content: space-between; padding: 16px 18px 8px; flex: 0 0 auto; }
.settings-head button { padding-inline: 8px; min-width: 44px; font-size: 12px; }
.settings-content { min-height: 0; overflow: auto; padding: 0 18px 18px; }
.settings-group { margin: 0; padding: 12px 0 14px; border: 0; border-bottom: 1px solid var(--line2); }
.settings-group:last-child { border-bottom: 0; padding-bottom: 0; }
.settings-group legend { float: left; width: 100%; margin-bottom: 12px; padding: 0; font-size: 12px; font-weight: 650; color: var(--fg); }
.settings-group > :nth-child(2) { clear: both; }
.setting-field { display: block; margin-top: 12px; }
.setting-field:first-of-type { margin-top: 0; }
.field-label { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 7px; font-size: 12px; color: var(--fg2); }
.field-label b { color: var(--fg); font-weight: 500; font-variant-numeric: tabular-nums; }
.field-label small { font-size: 11px; color: var(--fg3); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.field-grid .setting-field { margin: 0; }
.theme-select { position: relative; }
.theme-select select { padding-left: 33px; }
.theme-dot { position: absolute; width: 12px; height: 12px; top: 16px; left: 12px; border: 1px solid #c1c9d5; border-radius: 50%; pointer-events: none; }
.setting-help { margin: 6px 0 0; color: var(--fg3); font-size: 12px; line-height: 1.7; }
.switch-detail { min-width: 0; flex: 1; }
.switch-detail strong { display: block; font-size: 13px; color: var(--fg); font-weight: 500; }
.switch-detail small { display: block; margin-top: 4px; color: var(--fg3); font-size: 12px; }
.settings-group .switch { gap: 10px; padding-block: 6px; }
.settings-backdrop { display: none; }
.workspace-nav { display: none; }
.app[data-settings="closed"] .settings-panel { display: none; }
.app[data-settings="closed"] .workspace { grid-template-columns: minmax(300px, .9fr) minmax(360px, 1.35fr); }
.status { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; min-height: 34px; padding: 7px 24px; border-top: 1px solid var(--line); background: var(--panel); font-size: 12px; color: var(--fg2); }
.status .dot { width: 6px; height: 6px; flex: 0 0 auto; background: #28926a; border-radius: 50%; }
.status.err .dot { background: #c83636; }
.status.busy .dot { background: #b67409; animation: pulse 1s infinite; }
.status { flex-wrap: wrap; }
.filing-link { margin-left: auto; color: var(--fg2); font-size: 12px; line-height: inherit; text-underline-offset: 3px; }
.filing-link:focus-visible { outline: 3px solid #8baaff; outline-offset: 3px; }
#statusText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; }
#statusPath { min-width: 0; flex: 1; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg3); font-family: Consolas, monospace; font-size: 11px; }
.toast { position: fixed; bottom: 55px; left: 50%; transform: translate(-50%, 12px); padding: 12px 18px; max-width: min(560px, calc(100vw - 32px)); width: max-content; background: #202b3d; color: white; font-size: 13px; line-height: 1.65; text-align: center; border-radius: 10px; box-shadow: 0 6px 22px rgb(32 43 61 / 20%); pointer-events: none; opacity: 0; transition: opacity .18s, transform .18s; z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #a82c2c; }
@keyframes pulse { 50% { opacity: .35; } }
@media (max-width: 1199px) {
  .workspace, .app[data-settings="closed"] .workspace { grid-template-columns: minmax(270px, .9fr) minmax(330px, 1.2fr); }
  .topbar { gap: 16px; }
  .settings-panel { display: none; }
  .app[data-settings="open"] .settings-panel { display: flex; position: fixed; top: 16px; bottom: 16px; right: 16px; width: min(340px, calc(100vw - 32px)); z-index: 50; box-shadow: 0 16px 60px rgb(32 43 61 / 22%); }
  .app[data-settings="open"] .settings-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgb(23 35 56 / 35%); }
  .local-badge { display: none; }
}
@media (max-width: 767px) {
  .topbar { height: auto; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 12px 16px; }
  .brand-mark { width: 34px; height: 34px; font-size: 22px; border-radius: 10px; }
  .brand-name { font-size: 18px; }
  .brand-description { font-size: 11px; margin-top: 3px; }
  .header-actions { display: contents; }
  #btnExport { grid-column: 2; grid-row: 1; }
  #btnSettings { grid-column: 1; grid-row: 2; }
  #btnSave { grid-column: 2; grid-row: 2; }
  .workspace, .app[data-settings="closed"] .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: 44px minmax(0, 1fr); gap: 10px; padding: 10px 12px 12px; }
  .workspace-nav { display: flex; align-items: stretch; gap: 4px; background: #e6ebf4; border-radius: 10px; }
  .workspace-nav button { flex: 1; border-color: transparent; background: transparent; border-radius: 10px; }
  .workspace-nav button[aria-selected="true"] { background: var(--panel); color: var(--brand); box-shadow: 0 1px 4px rgb(32 43 61 / 9%); }
  .pane-l, .pane-r { grid-column: 1; grid-row: 2; }
  .app[data-view="editor"] .pane-r, .app[data-view="preview"] .pane-l { visibility: hidden; pointer-events: none; }
  .pane-head { min-height: 64px; padding: 9px 14px; }
  .pane-head p { font-size: 11px; }
  .pane-head button { font-size: 12px; padding-inline: 7px; }
  .editor-tools { padding: 7px 14px; gap: 8px; }
  .editor-tools select { font-size: 12px; width: 119px; }
  #src { font-size: 14px; padding: 16px; }
  .editor-footer { padding-left: 14px; gap: 4px; }
  .clean-wrap { gap: 3px; }
  .clean-wrap button { font-size: 12px; }
  .preview-wrap { padding: 16px; }
  .preview-footer { padding-inline: 14px; gap: 8px; }
  .preview-footer .theme-name { max-width: 30%; font-size: 11px; }
  .zoom-control { width: 200px; gap: 6px; }
  .zoom-control label { display: none; }
  .status { padding-inline: 16px; font-size: 11px; }
  #statusText { flex: 1; min-width: 0; }
  #statusPath { display: none; }
  .bubble { max-height: calc(100dvh - 200px); overflow: auto; }
}
@media (max-height: 650px) and (max-width: 767px) {
  .brand-description, .pane-head p { display: none; }
  .topbar { padding-block: 6px; row-gap: 4px; }
  .workspace, .app[data-settings="closed"] .workspace { padding-block: 8px 10px; row-gap: 8px; }
  .pane-head { min-height: 49px; padding-block: 2px; }
  .editor-tools { padding-block: 4px; }
  .editor-footer { padding-block: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
