/* ==================== 在线公式编辑器 ==================== */
.fm-card { padding: 16px; }

.fm-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.fm-head h1 { font-size: 1.35rem; font-weight: 700; margin-bottom: 2px; }
.fm-head-text { max-width: 760px; }
.fm-head-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.fm-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
    gap: 12px;
    align-items: start;
}
.fm-col-left, .fm-col-right { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.fm-panel {
    background: #fbfbfc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
}
.fm-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-bottom: 9px;
}
.fm-panel-head h2 { font-size: .9rem; font-weight: 700; margin: 0; }
.fm-count, .fm-status { font-size: .72rem; color: var(--text-dim); }

.fm-input {
    display: block; width: 100%; min-height: 118px;
    padding: 10px 12px;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: .86rem; line-height: 1.6;
    color: var(--field-text); background: #fff;
    border: 1px solid var(--field-border); border-radius: var(--field-radius);
    outline: none; resize: vertical;
    transition: border-color .15s, box-shadow .15s;
}
.fm-input:hover { border-color: var(--field-border-hover); }
.fm-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--field-focus-ring); }
.fm-input::placeholder { color: var(--field-placeholder); }
.fm-err {
    margin-top: 8px; padding: 7px 10px;
    font-size: .76rem; line-height: 1.5;
    color: #b42318; background: #fff2f0;
    border: 1px solid #ffccc7; border-radius: 7px;
}
.fm-err[hidden] { display: none; }
.fm-inline-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.fm-hint { font-size: .72rem; color: var(--text-dim); line-height: 1.6; margin-top: 8px; }

.fm-cats { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.fm-cat {
    padding: 4px 9px; font-size: .74rem; line-height: 1.4;
    color: var(--text-dim); background: #fff;
    border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.fm-cat:hover { border-color: var(--accent); color: var(--accent); }
.fm-cat.active { color: #fff; background: var(--accent); border-color: var(--accent); }

.fm-symbols {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 6px;
    max-height: 246px; overflow-y: auto;
    padding-right: 2px;
}
.fm-sym {
    min-height: 40px; padding: 5px 3px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: #fff; color: var(--text);
    border: 1px solid var(--border); border-radius: 7px; cursor: pointer;
    line-height: 1.25;
}
.fm-sym:hover { border-color: var(--accent); background: #fff8f5; }
.fm-sym .fm-sym-face { font-size: 1.02rem; font-family: "Cambria Math", "Times New Roman", serif; }
.fm-sym .fm-sym-name { font-size: .64rem; color: var(--text-dim); margin-top: 2px; }
.fm-sym.is-struct .fm-sym-face { font-size: .8rem; font-family: inherit; font-weight: 600; }

.fm-examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.fm-example {
    text-align: left; padding: 7px 9px;
    font-size: .74rem; line-height: 1.4;
    color: var(--text); background: #fff;
    border: 1px solid var(--border); border-radius: 7px; cursor: pointer;
}
.fm-example:hover { border-color: var(--accent); color: var(--accent); }
.fm-example small { display: block; color: var(--text-dim); font-size: .66rem; margin-top: 2px; }

.fm-recent { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; }
.fm-recent-item {
    max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    padding: 4px 8px; font-size: .7rem;
    font-family: ui-monospace, Consolas, monospace;
    background: #fff; color: var(--text);
    border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.fm-recent-item:hover { border-color: var(--accent); color: var(--accent); }

.fm-preview {
    min-height: 190px;
    display: flex; align-items: center; justify-content: center;
    padding: 14px;
    background-color: #fff;
    background-image: none;
    border: 1px solid var(--border); border-radius: 8px;
    overflow: auto;
}
/* 仅透明背景时显示棋盘格，提示导出图片也是透明的 */
.fm-preview.is-transparent {
    background-image: linear-gradient(45deg, #eaedf1 25%, transparent 25%),
                      linear-gradient(-45deg, #eaedf1 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #eaedf1 75%),
                      linear-gradient(-45deg, transparent 75%, #eaedf1 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.fm-out { max-width: 100%; color: #1f2430; }
.fm-out mjx-container { margin: 0 !important; }
.fm-out mjx-container[display="true"] { display: block; text-align: center; }
.fm-out mjx-container svg { max-width: none; }
/* MathJax 的辅助 MathML 供读屏软件使用；tex-svg 合并构建不会注入隐藏样式，
   Chrome 原生 MathML 会把它显示成第二份公式。这里显式隐藏，DOM 仍保留供「复制 MathML」。 */
.fm-out mjx-assistive-mml {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.fm-row { display: flex; align-items: center; gap: 8px; margin-top: 9px; font-size: .76rem; }
.fm-row:first-of-type { margin-top: 0; }
.fm-row > label { min-width: 66px; color: var(--text-dim); margin: 0; white-space: nowrap; }
.fm-row input[type="range"] { flex: 1; min-width: 0; }
.fm-row select { flex: 1; min-width: 0; font-size: .76rem; }
.fm-val { min-width: 44px; text-align: right; color: var(--text); }
.fm-swatch {
    width: 34px; height: 26px; padding: 0;
    border: 1px solid var(--field-border); border-radius: 5px;
    background: #fff; cursor: pointer;
}
.fm-notes { margin: 0; padding-left: 18px; font-size: .74rem; color: var(--text-dim); line-height: 1.8; }

@media (max-width: 980px) {
    .fm-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
    .fm-card { padding: 10px; }
    .fm-symbols { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); max-height: 210px; }
    .fm-preview { min-height: 150px; }
}
