/*
 * [INPUT]: fp-shell.css 外壳变量、index.html 工作台与 board-view.js 的格尺寸/视图及可用高度变量。
 * [OUTPUT]: MagicPath 卡片外壳适配下的 Crossmath 求解器棋盘样式、44px 控件、连续录入/确认/指南、广告位间距及窄屏布局。
 * [POS]: src 的 Crossmath 求解器专用视觉层，配合 /fp-shell.css 运行，零外部字体或图像。
 * [PROTOCOL]: 变更时更新此头部，然后检查 CLAUDE.md
 */
:root {
  --paper: #F8F8F3; --ink: #182B2C; --muted: #657470; --rule: #D9E1DB; --surface: #FFFFFF;
  --green: #225E55; --forest: #225E55; --coral: #EE6B4B; --lime: #E8F2B5;
  --serif: Georgia, Charter, 'Times New Roman', ui-serif, serif;
}
button, input, textarea, select { font: inherit; }
button, input, select, summary { min-height: 44px; }
button { cursor: pointer; border: 1px solid #CDD8CF; border-radius: 8px; background: #fff; color: var(--ink); padding: 8px 12px; font-weight: 670; }
button:disabled { cursor: default; opacity: .55; }
button:hover:not(:disabled) { border-color: var(--forest); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, .board-scroll:focus-visible { outline: 3px solid #D8784B; outline-offset: 2px; }
[hidden] { display: none !important; }
.workbench { background: var(--surface); border: 1px solid #D8DED6; border-radius: 15px; padding: 16px; margin-top: 18px; box-shadow: 0 3px 0 #E6E9E2; }
.grid-panel, .editor-panel { min-width: 0; }
.board-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
#board-size { color: #607268; font-size: 11px; margin-left: 4px; }
.board-top button { font-size: 11px; padding-inline: 8px; }
.board-tools, .board-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.board-controls { margin-top: 8px; }
.board-controls button { font-size: 12px; }
summary { cursor: pointer; padding-block: 10px; font-size: 12px; font-weight: 650; }
#layout { border-block: 1px solid #e2e6dc; margin-block: 8px 12px; }
.layout-fields { display: grid; grid-template-columns: repeat(auto-fit,minmax(76px,1fr)); gap: 8px; align-items: end; margin-bottom: 12px; }
.layout-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.layout-shortcuts button { font-size: 12px; }
.layout-shortcuts [aria-pressed="true"] { background: #edf3d4; border-color: #577500; }
.layout-edges { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
.layout-help { font-size: 12px; color: #607268; }
label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 6px; }
input, textarea, select { border: 1px solid #c8c4b6; border-radius: 4px; padding: 10px; background: #fff; color: var(--ink); width: 100%; min-width: 0; font-size: 16px; }
textarea { resize: vertical; min-height: 56px; }
label span { font-weight: 450; font-size: 11px; }
#layout-note { font-size: 11px; color: #607268; }
.danger { margin-bottom: 12px; color: #993c2e; }
#analytics-status { font-size: 12px; }
#confirmation { margin-block: 8px 12px; padding: 12px; border: 1px solid #d6ad69; border-radius: 4px; background: #fff3da; color: #744715; }
#confirmation h2 { margin: 0 0 4px; font-size: 15px; }
#confirmation p { margin: 0 0 10px; font-size: 12px; overflow-wrap: anywhere; }
#confirmation > div { display: flex; flex-wrap: wrap; gap: 8px; }
#confirmation button { font-size: 12px; }
#confirm-apply { color: #823426; border-color: #b99b6e; }
#result { border-radius: 4px; background: #f1f3e9; padding: 10px 12px; font-size: 12px; margin-bottom: 12px; }
#result[data-state="unique"] { background: #e9f3c5; }
#result[data-state="multiple"], #result[data-state="timeout"] { background: #fff3da; color: #744715; }
#result[data-state="invalid"], #result[data-state="error"] { background: #fff0e8; color: #823426; }
#detail { display: block; overflow-wrap: anywhere; }
#extend { display: block; margin-top: 8px; }
.board-scroll { width: 100%; max-height: var(--board-height); overflow: auto; padding: 4px; border-radius: 4px; background: #f5f5ee; overflow-anchor: none; }
.board-scroll[data-view="zoom"] { height: var(--board-height); }
#board { --edit-font: 18px; width: max-content; min-width: 100%; display: flex; flex-direction: column; gap: 2px; }
#board:empty { height: min(228px, max(88px, calc(55vh - 8px))); }
#board [role="row"] { display: grid; grid-template-columns: repeat(var(--columns), var(--cell-size,44px)); gap: 2px; justify-content: center; }
#board button { padding: 0; min-width: 0; min-height: 0; height: var(--cell-size,44px); border-radius: 2px; font-size: var(--cell-font,18px); font-weight: 650; font-variant-numeric: tabular-nums; position: relative; overflow: hidden; }
#board button[data-kind="number"] { background: #fffdf1; }
#board button[data-kind="operator"], #board button[data-kind="equals"] { background: #e9eee1; font-weight: 450; }
#board button[data-kind="void"] { background: transparent; border-color: transparent; color: #71806c; }
#board button[data-kind="void"]::before { content: '·'; }
#board button[data-kind="void"][aria-selected="true"] { border-color: #143d32; }
#board button[aria-selected="true"] { border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--lime); }
#board button.generated { color: #356300; background: #edf8c7; font-weight: 800; }
#board button.generated::after { content: '✓'; position: absolute; right: 1px; bottom: 0; font-size: min(10px,var(--cell-font,18px)); }
#board button.invalid { border: 2px solid #b64533; }
.board-help, #pool-count, .privacy { font-size: 12px; color: #607268; margin-block: 6px 10px; }
.cell-editor { border-top: 1px solid #e1e5da; padding-block: 12px; }
.editor-label { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 12px; }
.editor-label span { font-size: 9px; letter-spacing: 1px; color: #607268; }
#cell-types { display: grid; grid-template-columns: repeat(auto-fit,minmax(64px,1fr)); gap: 4px; margin-bottom: 8px; }
#cell-tools { display: flex; gap: 4px; margin-bottom: 8px; }
#cell-types button, #cell-tools button { font-size: 12px; flex: 1; min-width: 0; padding-inline: 6px; }
#cell-types button[aria-pressed="true"], #cell-tools button[aria-pressed="true"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.number-field { display: flex; gap: 6px; }
.number-field button { min-width: 44px; }
.field-error { color: #823426; font-size: 12px; margin-block: 4px 8px; }
input[aria-invalid="true"] { border: 2px solid #b64533; }
.entry-controls { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.entry-controls select { width: auto; flex: 1; min-width: 96px; padding-inline: 6px; }
.entry-controls button { font-size: 12px; padding-inline: 8px; }
.pool-meta { display: flex; align-items: center; gap: 8px; }
.pool-meta p { flex: 1; }
.pool-meta button { font-size: 12px; }
.cell-editor, .pool-editor { scroll-margin-block: 8px; }
.actions { padding-bottom: env(safe-area-inset-bottom,0px); }
.actions { display: flex; gap: 8px; }
#solve { flex: 1; background: var(--lime); border: 2px solid var(--ink); border-radius: 4px; min-height: 48px; display: flex; justify-content: space-between; align-items: center; }
.privacy { text-align: center; }
.equation-preview { border-top: 1px solid #e1e5da; font-size: 12px; }
.equation-preview p { color: #607268; }
.guide { max-width: 100%; margin-block: 28px 44px; display: grid; gap: 14px; }
.guide section { background: var(--surface); border: 1px solid #D8DED6; border-radius: 15px; padding: 20px 24px; scroll-margin-top: 16px; }
.guide h2 { font-size: 20px; font-weight: 820; letter-spacing: -.5px; margin: 0 0 10px; }
.guide h3 { font-size: 16px; font-weight: 800; margin-top: 20px; }
.guide-nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.guide a { color: inherit; text-underline-offset: 4px; }
.guide-nav a { display: inline-flex; align-items: center; min-height: 44px; font-size: 13px; }
.guide ol { padding-left: 24px; font-size: 14px; color: #4c645b; }
.guide li { margin-bottom: 12px; }
.example-grid { width: min(100%,280px); border-collapse: separate; border-spacing: 3px; table-layout: fixed; text-align: center; font-variant-numeric: tabular-nums; }
.example-grid caption { text-align: left; color: #4c645b; font-size: 12px; padding-bottom: 8px; }
.example-grid td { height: 40px; border: 1px solid #cdd7c6; border-radius: 2px; background: #fffef8; }
.guide .example-note { font-size: 12px; }
.rule-comparison { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 14px; text-align: left; }
.rule-comparison caption { text-align: left; color: #4c645b; font-size: 12px; padding-bottom: 8px; }
.rule-comparison th, .rule-comparison td { padding: 10px 8px; border-bottom: 1px solid #d2d8cd; overflow-wrap: anywhere; }
.result-guide { font-size: 14px; }
.result-guide dt { font-weight: 700; margin-top: 16px; }
.result-guide dd { color: #4c645b; margin: 4px 0 12px; }
.guide details { border-top: 1px solid #d2d8cd; }
.guide summary { font-size: 14px; }
.development-note { border-left: 3px solid #b5ce5b; padding-left: 16px; }
@media (min-width: 760px) {
  .workbench { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 28px; padding: 22px; }
  .editor-panel { border-left: 1px solid #e1e5da; padding-left: 24px; }
  .cell-editor { border-top: 0; padding-top: 0; }
}
@media (max-width: 380px) {
  .intro { margin-block: 4px 8px; }
  .intro .eyebrow { display: none; }
  .intro > p:last-child { font-size: 12px; }
  .board-top { flex-wrap: wrap; }
  #cell-tools { gap: 3px; margin-bottom: 4px; }
  .cell-editor { padding-block: 8px; }
  .editor-label { margin-bottom: 4px; }
  #pool { height: 56px; }
  #pool-count { margin-block: 6px 10px; }
}
