:root {
  color-scheme: light;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --surface: #f5f7fa;
  --accent: #0062ff;
  --accent-hover: #0050cc;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: white;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; line-height: 1.7; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
a { color: var(--accent); }
.guide-tools { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 7px; min-height: 50px; margin-bottom: 10px; }
.guide-tools .first-guide { background: var(--accent); color: white; border-color: var(--accent); }
.guide-tools .first-guide:hover { background: var(--accent-hover); color: white; }
h2 { font-size: 17px; margin: 0 0 10px; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.workspace {
  max-width: 1760px;
  margin-inline: auto;
  padding: 14px clamp(16px, 2vw, 32px) 28px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 300px;
  grid-template-areas: "setup stage options";
  gap: 16px;
  align-items: start;
}
.setup { grid-area: setup; }
.stage { grid-area: stage; min-width: 0; position: sticky; top: 74px; }
.options { grid-area: options; }
.setup .shape-picker { flex: 1 1 100%; align-items: stretch; flex-direction: column; }
.setup .paper-tools { row-gap: 7px; }
.edit-actions:not(:empty) { margin-top: 4px; }
.selection-tools { margin: 8px 0; padding: 8px 0; border-block: 1px solid #e5edee; scroll-margin-top: 92px; }
.selection-tools h2, .more-construction h2 { font-size: 14px; margin-bottom: 4px; }
.selection-tools p { font-size: 12px; margin: 0 0 6px; }
.selection-tools[data-selection] p { color: #17488d; font-weight: 600; }
.selection-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.tool-requirement { min-width: 0; }
.tool-requirement button { width: 100%; font-size: 13px; padding-inline: 3px; }
.tool-requirement button:disabled { pointer-events: none; }
.selection-grid button:disabled, .drawing-toolbar button:disabled { background: #eef2f6; color: #6b788b; opacity: 1; }
.selection-tools .selection-grid button:enabled { border-color: #80adfa; background: #e7f1ff; color: #084fb9; font-weight: 650; }
.selection-tools .selection-grid button:enabled:hover { border-color: var(--accent); background: #d5e6ff; }
.drawing-toolbar button[aria-pressed=true]:enabled, .more-construction button[aria-pressed=true]:enabled {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 650;
}
.options .context-tools { margin-bottom: 10px; }
.options .fold-options { margin: 0 0 12px; }
.panel h2 { color: var(--muted); font-size: .78rem; letter-spacing: .08em; }
.options h2 { margin-bottom: 0; }
.buttons, .controls { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.controls { margin-top: 10px; }
button, .button, summary {
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: inherit;
  cursor: pointer;
  font-size: .85rem;
}
button:not(:disabled):hover, .button:hover, summary:hover { border-color: var(--accent); color: var(--accent); }
button[aria-pressed=true], details[open] > summary { border-color: var(--accent); background: #f0f6ff; color: var(--accent); }
button:disabled { opacity: .52; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: white; }
.primary:not(:disabled):hover { background: var(--accent-hover); color: white; }
summary { width: max-content; max-width: 100%; }
.guide { flex: 0 0 auto; }
.guide > summary { font-size: 14px; }
.guide > p { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 8px 0 0; }
.guide[open] { flex: 1 1 180px; }
.walkthrough { padding: 10px 12px; margin-bottom: 10px; border: 1px solid #bfdbfe; border-radius: 8px; background: #eff6ff; }
.walkthrough p { color: #1e3a8a; font-size: 14px; margin: 0 0 8px; }
.walkthrough .buttons button { min-height: 30px; padding-block: 4px; }
.guide-target { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd { border-radius: 3px; background: #e2ecec; padding: 1px 4px; }
.paper-tools { margin-bottom: 9px; }
.shape-picker { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.shape-picker select, .point-names input, #newName, #boardName {
  min-width: 0;
  padding: 7px;
  border: 1px solid #c9d9dd;
  border-radius: 7px;
  background: white;
  color: inherit;
}
.shape-picker.shape-start select {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #dbe9ff;
  background: #edf5ff;
  color: #0050cc;
  font-weight: 600;
  scroll-margin-block: 88px 12px;
}
.upload { position: relative; }
.upload input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.upload:focus-within { outline: 2px solid var(--accent); }
.drawing-toolbar { padding: 8px 0; border-top: 1px solid #e5edee; }
.fold-menu { position: relative; }
.fold-menu-items {
  position: absolute;
  z-index: 2;
  min-width: max-content;
  display: grid;
  gap: 5px;
  padding: 7px;
  background: white;
  box-shadow: 0 6px 18px #243c4826;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.context-tools { padding: 7px 9px; border-radius: 8px; background: #eef2f7; font-size: 14px; }
.context-tools button { min-height: 32px; padding-block: 4px; }
#readout { font-weight: 600; }
.muted, footer { color: var(--muted); font-size: 14px; }
.tool-status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 11px;
  margin: 0 0 8px;
  padding: 8px 11px;
  border: 1px solid #cbdfff;
  border-radius: 8px;
  background: #f0f6ff;
  color: #173763;
  scroll-margin-top: 92px;
}
.tool-status strong { font-size: .93rem; color: #084fb9; }
.tool-status #hint { flex: 1 1 16em; margin: 0; font-size: .9rem; line-height: 1.5; }
#selectionJump { display: none; font-size: .82rem; font-weight: 600; text-underline-offset: 2px; }
.canvas-frame > #hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgb(255 255 255 / 82%);
  color: var(--muted);
  font-size: .74rem;
  line-height: 1.5;
  pointer-events: none;
}
.canvas-frame {
  position: relative;
  width: 100%;
}
canvas {
  display: block;
  width: 100%;
  aspect-ratio: 900 / 610;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  touch-action: manipulation;
  cursor: crosshair;
}
.canvas-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  pointer-events: none;
  text-align: center;
}
.canvas-guide strong { font-size: clamp(14px, 1.6vw, 18px); }
.canvas-guide span { color: var(--muted); font-size: clamp(12px, 1.3vw, 15px); }
.canvas-guide #startShape {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  font-weight: 700;
  font-size: clamp(14px, 1.6vw, 18px);
  text-underline-offset: 3px;
}
.canvas-guide .shape-start-arrow { color: inherit; font-size: 1.18em; line-height: 1; }
.shape-start-arrow::before { content: "↖"; }
@media (max-width: 880px) {
  .tool-status {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 2px 8px;
  }
  .tool-status strong { grid-area: 1 / 1; }
  .tool-status #hint { grid-area: 2 / 1 / 3 / -1; min-height: 3em; }
  #selectionJump { display: inline; grid-area: 1 / 2; justify-self: end; }
  .shape-start-arrow::before { content: "↓"; }
}
@media (min-width: 681px) and (max-width: 880px) {
  .tool-status #hint { min-height: 1.5em; }
}
canvas.drawing-shape, canvas.orbiting { touch-action: none; }
canvas.orbiting { cursor: grab; }
canvas.orbiting:active { cursor: grabbing; }
#angle { flex: 1; min-width: 75px; accent-color: var(--accent); }
output { min-width: 3.5ch; font-variant-numeric: tabular-nums; }
.fold-options { color: var(--muted); font-size: 14px; gap: 7px 12px; }
.board-actions { margin-top: 7px; }
#pointOptions[open] { flex: 1 1 100%; }
.point-names { display: grid; grid-template-columns: repeat(auto-fit, minmax(124px, 1fr)); gap: 6px; margin-top: 8px; max-height: 200px; overflow: auto; }
.point-names label { display: grid; grid-template-columns: 3.7em minmax(0,1fr); gap: 5px; align-items: center; font-size: 13px; }
.point-names label.selected-point { color: #8b3916; font-weight: 700; }
.point-names .selected-point input { border-color: #b04c1d; background: #fff3dd; }
.board-status:empty { display: none; }
.board-status { margin: 8px 0 0; }
dialog { width: min(380px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 12px; padding: 18px; color: var(--ink); }
dialog::backdrop { background: #152c4260; }
#renameForm { display: grid; gap: 12px; }
#renameForm .buttons { justify-content: flex-end; }
#boardDialogStatus { margin: 8px 0 12px; }
#boardQr { text-align: center; margin: 12px 0; }
#boardQr img { width: 200px; height: 200px; max-width: 100%; object-fit: contain; }
#saveForm { margin-bottom: 14px; }
#boardName { display: block; width: 100%; margin-top: 5px; }
#saveForm .muted { margin: 8px 0; }
#boardList { list-style: none; padding: 0; max-height: 270px; overflow: auto; }
#boardList button { width: 100%; text-align: left; overflow-wrap: anywhere; }
#boardList li + li { margin-top: 6px; }
@media (min-width: 1560px) {
  .workspace { grid-template-columns: 240px minmax(0, 1fr) 320px; }
}
@media (max-width: 1179px) {
  .workspace { grid-template-columns: 264px minmax(0, 1fr); grid-template-areas: "setup stage" "options stage"; }
}
@media (max-width: 880px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "setup" "options"; }
  .stage { position: static; }
}
@media (max-width: 680px) {
  .panel { padding: 8px; }
  .setup .shape-picker { flex: 0 1 auto; flex-direction: row; align-items: center; }
  .setup > h2 { display: none; }
  .selection-grid { grid-template-columns: repeat(auto-fit, minmax(72px,1fr)); }
  .paper-tools, .drawing-toolbar, .controls { font-size: 14px; }
  button, .button, summary { padding-inline: 8px; }
}
#lengthForm { display: grid; gap: 12px; }
#lengthValue { min-width: 0; padding: 7px; border: 1px solid #c9d9dd; border-radius: 7px; }
#lengthForm .buttons { justify-content: flex-end; }
