/* DESIGN WORKBENCH — edit this file to tune the interface.
   Reference: cbhua.github.io and /prompt/. Does not change paper/chart fonts.
   1. Shared palette/type. 2. Setup page. 3. Editor page. 4. Controls. */
:root {
  --bg: #faf8ec;
  --card: #fffef9;
  --ink: #333333;
  --muted: #77766e;
  --line: #dfded3;
  --accent: #296fa3;
  --radius: 6px;
  --ui-font: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, sans-serif;
  --setup-width: 760px;
  --sidebar-width: 320px;
  --editor-width: 60vw;
  --editor-min-width: 860px;
  --editor-max-width: 1440px;
  --preview-height: 80vh;
  --page-gutter: 28px;
}
body { font-family: var(--ui-font); font-size: 12px; line-height: 1.45; }
button,input,select,textarea { font: inherit; color: inherit; }
button { transition: background .12s, border-color .12s; }
button:not(:disabled):hover { border-color: var(--accent); }
select,input[type=number],input[type=file],textarea {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 9px;
}
textarea:focus,select:focus,input:focus-visible { outline: 2px solid #296fa333; border-color: var(--accent); }
/* SETUP PAGE — spacing, choice cards, and grid density */
#setup { max-width: var(--setup-width); margin: 48px auto; padding: 0 24px; }
#setup .setup-card { background: transparent; border: 0; border-radius: 0; box-shadow: none; padding: 0; }
#setup h1 { font-size: 24px; font-weight: 600; margin: 0 0 32px; letter-spacing: -.025em; }
#setup h2 { font-size: 13px; margin: 0 0 12px; letter-spacing: 0; }
#setup .setup-section { margin-bottom: 28px; }
#setup .setup-choices { gap: 10px; }
#setup .setup-choice { border-radius: var(--radius); background: var(--card); padding: 16px; gap: 4px; }
#setup .setup-choice strong { font-size: 14px; font-weight: 500; }
#setup .setup-choice[aria-pressed=true] { border-color: var(--accent); background: #edf3f5; box-shadow: inset 0 0 0 1px var(--accent); }
#setup .grid-choices { grid-template-columns: repeat(4,minmax(0,1fr)); }
#setup .grid-choices .setup-choice { flex-direction: row; align-items: center; gap: 12px; padding: 10px 14px; }
#setup .grid-choices strong { font-size: 12px; }
#setup .grid-icon { width: 36px; height: 24px; gap: 2px; margin: 0; }
#setup .grid-icon i { border-color: #a4afb3; background: #e6ebeb; border-radius: 1px; }
#setup .setup-actions { margin-top: 8px; padding-top: 20px; }
#setup .primary-button { padding: 10px 24px; font-size: 12px; }
/* EDITOR PAGE — preview and independently scrolling control pane */
#editor .layout { width: clamp(var(--editor-min-width),var(--editor-width),var(--editor-max-width)); max-width: calc(100% - 48px); margin: max(24px,calc(10vh - 40px)) auto; grid-template-columns: minmax(0,1fr) var(--sidebar-width); padding: 0; gap: 24px; }
#editor .preview { overflow: auto; position: sticky; top: 0; max-height: calc(var(--preview-height) + 40px); padding: 0 4px 8px; }
#editor .preview-tools { margin: 0 0 8px; display: flex; justify-content: center; position: sticky; left: 0; top: 0; z-index: 3; background: var(--bg); padding: 8px 0; }
#editor .toolbar-zoom { margin: 0; width: 230px; }
#editor .toolbar-label { text-transform: none; letter-spacing: 0; font-size: 11px; }
#editor .side { top: 20px; max-height: calc(var(--preview-height) + 40px); gap: 14px; padding-right: 4px; scrollbar-width: thin; scrollbar-gutter: stable; overflow-anchor: none; }
#editor .card { flex-shrink: 0; padding: 16px; background: var(--card); }
#editor .card h2 { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); margin-bottom: 12px; }
#editor .card-head h2 { margin: 0; }
#editor .card-head { margin-bottom: 10px; }
#editor .paper-scale { filter: drop-shadow(0 2px 5px #33333318); }
#editor .reflow-paper { overflow: hidden; }
#editor .preview-status:not([data-kind=error]) { display: none; }
#editor .status-detail { font-size: 11px; }
#editor #wrap-note, #editor .check-open { display: none; }
/* Export readiness changes button availability, never card geometry. */
#editor .export-state { display: none; }
#editor .buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#editor .buttons button { padding: 8px; font-size: 11px; }
#editor #download-svg:not(:disabled) { background: var(--accent); border-color: var(--accent); color: white; }
#editor #copy-handoff:not(:disabled) { background: #edf3f5; border-color: #bfd0d8; color: var(--accent); }
#editor .figure-content .toolbar-group { display: grid; grid-template-columns: 70px minmax(0,1fr); margin: 10px 0 0; }
#editor .figure-content input, #editor .figure-content select { width: 100%; min-width: 0; font-size: 11px; }
#editor .paper-setting { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 6px; }
#editor .paper-setting input { width: 76px; padding: 4px 6px; text-align: right; }
#editor #figure-height-slider, #editor #figure-width-slider { width: 100%; --steps: 30; }
#editor .panel-group { padding-top: 16px; margin-top: 16px; }
#editor .panel-group h3 { text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--ink); margin-bottom: 12px; }
#editor .panel-note { font-size: 11px; line-height: 1.6; }
#editor .control { margin-bottom: 12px; gap: 6px; }
#editor .control-label { font-size: 12px; }
#editor .control-inputs { grid-template-columns: minmax(0,1fr) 58px 25px 30px; gap: 7px; }
#editor .control-inputs:has(.weight-slider) { grid-template-columns: minmax(0,1fr) 30px; }
#editor .control-inputs input[type=number] { padding: 3px 5px; font-size: 11px; }
#editor .control-unit { font-size: 10px; min-width: 0; white-space: nowrap; }
#editor .control-reset { font-size: 10px; border: 0; padding: 3px; background: transparent; }
#editor .weight-legend, #editor .range-legend { display: flex; justify-content: space-between; font-size: 9px; color: var(--muted); }
#editor .weight-legend { padding-right: 37px; }
#editor .range-legend { padding-right: 134px; margin-top: -3px; }
/* CONTROLS — discrete movement, visible track divisions, no default blue pill */
input[type=range] { --steps: 20; appearance: none; -webkit-appearance: none; height: 16px; margin: 4px 0; border: 0; border-radius: 0; background: transparent; cursor: pointer; min-width: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 7px; border: 1px solid #c7c8bf; border-radius: 2px; background: repeating-linear-gradient(to right,transparent 0,transparent calc(100% / var(--steps) - 1px),#bec7c7 calc(100% / var(--steps) - 1px),#bec7c7 calc(100% / var(--steps))),linear-gradient(to right,#b6ccd5 var(--fill,0%),#e8e8dd var(--fill,0%)); }
input[type=range]::-webkit-slider-thumb { appearance: none; width: 11px; height: 17px; margin-top: -6px; border: 1px solid #1f5b83; border-radius: 3px; background: var(--accent); }
input[type=range]::-moz-range-track { height: 6px; border: 1px solid #c7c8bf; background: #e8e8dd; }
input[type=range]::-moz-range-thumb { width: 10px; height: 16px; border: 1px solid #1f5b83; border-radius: 3px; background: var(--accent); }
input[type=range]:disabled { opacity: .45; cursor: default; }
@media(max-width:900px) {
  #editor .layout { width: auto; max-width: none; margin: 24px 12px; grid-template-columns: minmax(0,1fr); padding: 0; }
  #editor .preview { position: static; max-height: none; }
  #editor .side { position: static; max-height: none; padding: 0; }
  #setup { margin: 28px auto; padding: 0 18px; }
  #setup .template-choices { grid-template-columns: repeat(3,minmax(0,1fr)); }
  #setup .width-choices { grid-template-columns: repeat(2,minmax(0,1fr)); }
  #setup .grid-choices .setup-choice { flex-direction: column; padding: 10px 6px; gap: 6px; }
}
/* Assessment and warning rail. Expanding warnings never moves the controls. */
#editor .layout { position: relative; }
#editor .figure-assessment { flex-shrink: 0; height: 44px; width: 100%; text-align: left; padding: 10px 16px; font-weight: 600; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); cursor: pointer; }
#editor .figure-assessment:disabled { color: var(--muted); cursor: default; }
#editor .figure-assessment[data-state=warn] { color: #845e20; }
#editor .buttons { grid-template-columns: 1fr; }
#editor #copy-handoff { min-height: 36px; }
#editor #warning-rail { position: absolute; right: calc(100% + 16px); top: 48px; width: clamp(160px,13vw,210px); max-height: var(--preview-height); overflow: auto; scrollbar-width: thin; }
#editor #warning-rail .checks { margin: 0; max-width: none; }
#editor .warning-card { list-style: none; margin: 0 0 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); font-size: 11px; overflow-wrap: anywhere; }
#editor .warning-card strong { font-size: 12px; font-weight: 600; }
#editor .warning-card p { color: var(--muted); margin: 8px 0 0; line-height: 1.6; }
#editor .figure-content select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m2 2 4 4 4-4' fill='none' stroke='%2377766e' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
@media(min-width:901px) and (max-width:1100px) {
  #editor #warning-rail { position: static; grid-column: 1; grid-row: 2; width: auto; }
  #editor .preview { grid-column: 1; grid-row: 1; }
  #editor .side { grid-column: 2; grid-row: 1; }
}
@media(max-width:900px) {
  #editor .layout { display: flex; flex-direction: column; }
  #editor .preview, #editor .side { width: 100%; }
  #editor #warning-rail { position: static; width: 100%; }
}
#editor .warning-action { margin-top: 2px; padding: 4px 0; border: 0; background: transparent; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
#editor .setting-highlight { border-radius: 4px; background: #e5f0f3; outline: 4px solid #e5f0f3; transition: background .2s; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
/* Low-frequency controls are disclosure groups; primary type/line controls open. */
#editor .panel-group > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 600; padding: 2px 0 12px; color: var(--ink); }
#editor .panel-group > summary::-webkit-details-marker { display: none; }
#editor .panel-group > summary::after { content: '+'; color: var(--muted); font-weight: 400; font-size: 16px; }
#editor .panel-group[open] > summary::after { content: '−'; }
#editor .panel-group:not([open]) { padding-top: 10px; margin-top: 10px; }
#editor .panel-group:not([open]) > summary { padding-bottom: 0; }
#editor .data-origin { color: var(--muted); font-size: 10px; }
#editor .style-actions { display: flex; gap: 8px; }
#editor .style-actions button { border: 0; background: transparent; font: inherit; font-size: 10px; color: var(--accent); padding: 4px 0; cursor: pointer; }
#editor .style-actions button:disabled { color: var(--muted); opacity: .45; cursor: default; }
@media(prefers-reduced-motion:reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
#editor .warning-card { transition: border-color .15s; }
#editor .warning-card:hover, #editor .warning-card:focus-within { border-color: #b4925e; }
#editor .warning-card:focus-visible { outline: 2px solid #b4925e; outline-offset: 2px; }
#editor [data-issue-overlay] { pointer-events: none; }
#editor .issue-figure { outline: 2px solid #b4925e; outline-offset: 3px; }

/* Keep the native, keyboard-accessible file input aligned with other controls. */
#editor input[type=file]::file-selector-button { border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--accent); font: inherit; padding: 3px 8px 3px 0; margin-right: 8px; cursor: pointer; }

/* Language selector is available in setup and remains reachable in the editor. */
.language-toolbar { position:fixed; top:16px; right:24px; z-index:20; color:var(--muted); font-size:12px; }
.language-toolbar button { padding:6px 10px; border:1px solid transparent; border-radius:var(--radius); background:var(--bg); cursor:pointer; }
.language-toolbar button:hover { background:var(--card); }
.language-toolbar button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
#ui-language[data-language=en] [data-language=en], #ui-language[data-language=zh] [data-language=zh] { color:var(--accent); font-weight:600; }
#editor .figure-assessment { cursor:default; }
#editor .figure-assessment[data-state=ok]:not(:disabled) { color:#286140; background:#eaf3e7; border-color:#c3d9bb; }
#editor .figure-assessment[data-state=warn]:not(:disabled) { color:#805d17; background:#fff3cd; border-color:#e8d28f; }
#editor .file-picker { position:relative; display:block; padding:7px 9px; border:1px solid var(--line); border-radius:var(--radius); background:var(--card); color:var(--accent); cursor:pointer; }
#editor .file-picker:focus-within { outline:2px solid #296fa355; }
:lang(zh-CN) .weight-legend { letter-spacing:0; }
#editor .figure-assessment { transition:none; }
