
  :root {
    --bg: #f3f1ee; --panel: #fff; --panel2: #ebe8e3; --line: #cfc9c0; --fg: #222; --mute: #6b655c;
    --accent: #8a5a2b; --btn: #efe4d4; --btn-b: #b98f5f; --ok: #d6eadf; --ok-b: #5f9a7e; --stage: #dcd8d1;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #181818; --panel: #222; --panel2: #2d2d2d; --line: #3d3d3d; --fg: #eee; --mute: #aaa;
      --accent: #d4a373; --btn: #3a3228; --btn-b: #634b32; --ok: #2e4a3d; --ok-b: #48735f; --stage: #111;
    }
  }
  :root[data-theme="dark"] {
    --bg: #181818; --panel: #222; --panel2: #2d2d2d; --line: #3d3d3d; --fg: #eee; --mute: #aaa;
    --accent: #d4a373; --btn: #3a3228; --btn-b: #634b32; --ok: #2e4a3d; --ok-b: #48735f; --stage: #111;
  }
  html { scroll-padding-top: env(safe-area-inset-top, 0px); height: 100%; }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { height: 100%; font-family: system-ui, sans-serif; background: var(--bg); color: var(--fg); display: flex; overflow: hidden; }
  #sidebar { width: 290px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: 18px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
  h2 { font-size: 1rem; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-top: 4px; }
  label { font-size: .85rem; color: var(--mute); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  select, input[type=range], input[type=color], button, .f-btn { width: 100%; margin-top: 4px; background: var(--panel2); color: var(--fg); border: 1px solid var(--line); padding: 9px; border-radius: 6px; font-size: .9rem; }
  input[type=color] { padding: 2px; height: 34px; width: 56px; margin: 0; }
  button, .f-btn { cursor: pointer; background: var(--btn); border-color: var(--btn-b); text-align: center; display: block; }
  button:focus-visible, .f-btn:focus-within, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .canon { display: flex; align-items: center; gap: 10px; color: var(--fg); background: var(--panel2); padding: 8px 10px; border-radius: 6px; }
  .canon span { flex: 1; font-size: .85rem; }
  .canon input[type=checkbox] { width: 18px; height: 18px; }
  .legend { font-size: .8rem; color: var(--mute); display: flex; gap: 14px; align-items: center; }
  .dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
  #err { display: none; position: absolute; left: 8px; right: 8px; top: 8px; z-index: 5; background: #fff3cd; color: #5c4400; border: 1px solid #e0b84b; border-radius: 6px; padding: 10px 12px; font-size: .85rem; line-height: 1.4; }
  #viewport { position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--stage); padding: 8px; }
  canvas { flex: none; display: block; touch-action: none; cursor: crosshair; box-shadow: 0 4px 20px rgba(0,0,0,.45); }
  button, label, input, select { touch-action: manipulation; }
  canvas { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  @media (pointer: coarse) { select, input[type=number] { font-size: 16px; } }
  @media (max-width: 600px) {
    body { flex-direction: column-reverse; }
    #sidebar { width: 100%; max-height: 46%; border-right: 0; border-top: 1px solid var(--line); }
  }
