  :root {
    --panel-bg: rgba(255,255,255,0.88);
    --ink: #1d2433;
    --muted: #5a6478;
    --accent: #e8413c;
    --accent-ink: #fff;
    --btn-bg: #eef1f6;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; overflow: hidden; background: #9fd3ff; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: var(--ink); }
  canvas { display: block; touch-action: none; }
  body.locked #panel,
  body.locked #toolsPanel,
  body.locked #hud,
  body.locked #toast,
  body.locked #debugPanel,
  body.locked canvas { visibility: hidden; pointer-events: none; }
  #loginOverlay {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    background:
      radial-gradient(ellipse 80% 60% at 50% 30%, rgba(255,255,255,0.35), transparent 70%),
      linear-gradient(180deg, #7ec4f0 0%, #9fd3ff 45%, #b8e0a8 100%);
  }
  #loginOverlay[hidden] { display: none !important; }
  .login-card {
    width: min(340px, calc(100vw - 32px));
    background: var(--panel-bg); backdrop-filter: blur(6px); border-radius: 12px;
    padding: 20px 18px; box-shadow: 0 4px 18px rgba(0,0,0,0.15);
    display: flex; flex-direction: column; gap: 8px;
  }
  .login-card h1 { margin: 0; font-size: 20px; }
  .login-sub { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
  .login-field { font-size: 12px; font-weight: 600; color: var(--muted); }
  .login-card input {
    font: inherit; padding: 8px 10px; border: 1px solid #cfd5df; border-radius: 8px;
    background: #fff; color: var(--ink);
  }
  .login-card input:focus { outline: 2px solid #3d6ea8; outline-offset: 1px; }
  .login-error { margin: 0; color: var(--accent); font-size: 12px; font-weight: 600; }
  .login-error[hidden] { display: none; }
  .login-card button { margin-top: 6px; width: 100%; }
  .panel-card {
    background: var(--panel-bg); backdrop-filter: blur(6px); border-radius: 12px;
    padding: 12px 14px; box-shadow: 0 4px 18px rgba(0,0,0,0.15); font-size: 13px; line-height: 1.4;
  }
  #panel {
    position: fixed; top: 12px; left: 12px; max-width: min(340px, calc(100vw - 24px));
    max-height: calc(100vh - 24px); overflow-y: auto;
  }
  #panel {
    background: var(--panel-bg); backdrop-filter: blur(6px); border-radius: 12px;
    padding: 12px 14px; box-shadow: 0 4px 18px rgba(0,0,0,0.15); font-size: 13px; line-height: 1.4;
  }
  #toolsPanel {
    position: fixed; top: 12px; right: 12px; max-width: min(280px, calc(100vw - 24px));
  }
  #toolsPanel[hidden] { display: none !important; }
  .tools-title { font-weight: 700; margin: 0 0 8px; font-size: 14px; }
  #panel h1 { margin: 0 0 6px; font-size: 18px; }
  .title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  button.small { padding: 3px 8px; font-size: 11px; }
  #panel ul { margin: 0 0 10px; padding-left: 18px; color: var(--muted); }
  .btns { display: flex; flex-wrap: wrap; gap: 6px; }
  button {
    font: inherit; border: 0; border-radius: 8px; padding: 7px 12px; cursor: pointer;
    background: var(--btn-bg); color: var(--ink); font-weight: 600;
  }
  button:hover { filter: brightness(0.95); }
  button.primary { background: var(--accent); color: var(--accent-ink); }
  .selbox { margin-top: 8px; padding: 8px; background: rgba(29,36,51,0.06); border-radius: 8px; display: flex; flex-direction: column; gap: 6px; }
  .selbox[hidden] { display: none; }
  .selbox button { padding: 4px 10px; }
  .toolbar { display: flex; gap: 0; margin: 4px 0 8px; }
  .toolbar button { border-radius: 0; flex: 1; }
  .toolbar button:first-child { border-radius: 8px 0 0 8px; }
  .toolbar button:last-child { border-radius: 0 8px 8px 0; }
  .toolbar button[aria-pressed="true"] { background: var(--ink); color: #fff; }
  .edit-bar, .draw-bar { margin: 0; }
  .edit-bar[hidden], .draw-bar[hidden] { display: none !important; }
  .edit-bar button[aria-pressed="true"], .draw-bar button[aria-pressed="true"] {
    background: var(--ink); color: #fff;
  }
  .icon-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-width: 36px; min-height: 36px; padding: 7px;
  }
  .icon-btn.wide { padding: 7px 12px; }
  .icon-btn .ico { width: 18px; height: 18px; flex: 0 0 auto; display: block; }
  .icon-btn .ico-text { font-size: 12px; }
  .edit-bar .icon-btn, .draw-bar .icon-btn:not(.wide) { flex: 0 0 auto; }
  @media (max-width: 720px) {
    #toolsPanel { top: auto; bottom: 12px; right: 12px; left: 12px; max-width: none; }
  }
  button:disabled { opacity: 0.45; cursor: default; filter: none; }
  .btns + .btns { margin-top: 6px; }
  details.box { margin-top: 10px; border-top: 1px solid rgba(29,36,51,0.12); padding-top: 8px; }
  details.box summary { cursor: pointer; font-weight: 600; margin-bottom: 6px; }
  .row { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
  .auto-assist {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--ink);
    cursor: pointer;
    user-select: none;
  }
  .auto-assist input { accent-color: #3d6ea8; }
  .row input, .row select { font: inherit; flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid #cfd5df; border-radius: 8px; background: #fff; color: var(--ink); }
  #hud {
    position: fixed; right: 12px; top: 12px; background: rgba(20,24,34,0.72); color: #fff;
    border-radius: 12px; padding: 10px 14px; font-variant-numeric: tabular-nums; min-width: 150px;
  }
  #hud .big { font-size: 30px; font-weight: 800; line-height: 1; }
  #hud .small { font-size: 12px; opacity: 0.8; margin-top: 4px; }
  #hud .state { font-size: 13px; font-weight: 700; margin-top: 6px; color: #ffc928; }
  #toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    background: rgba(20,24,34,0.85); color: #fff; padding: 8px 14px; border-radius: 10px;
    font-size: 14px; opacity: 0; transition: opacity .25s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
  }
  #toast.show { opacity: 1; }
  body.riding .build-only { display: none !important; }
  body:not(.riding) .ride-only { display: none !important; }
  @media (max-width: 520px) {
    #panel { font-size: 12px; padding: 10px; }
    #panel ul { display: none; }
    #hud .big { font-size: 22px; }
  }

  /* debug panel */
  .debug-panel {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 20;
    max-width: min(300px, calc(100vw - 24px));
    max-height: min(70vh, calc(100vh - 24px));
    overflow: auto;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    border-radius: 10px;
    padding: 8px 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    font-size: 11px;
    line-height: 1.35;
    color: var(--ink);
  }
  .debug-panel summary {
    cursor: pointer;
    font-weight: 700;
    font-size: 12px;
    margin-bottom: 6px;
    user-select: none;
  }
  .debug-telemetry { margin-bottom: 8px; }
  .debug-kv {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 10px;
    margin: 0;
    font-variant-numeric: tabular-nums;
  }
  .debug-kv dt { margin: 0; color: var(--muted); font-weight: 600; }
  .debug-kv dd { margin: 0; text-align: right; }
  .debug-phys-title {
    font-weight: 700;
    margin: 4px 0 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(29, 36, 51, 0.1);
    font-size: 11px;
  }
  .debug-slider {
    display: block;
    margin-bottom: 6px;
    cursor: default;
  }
  .debug-slider-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
  }
  .debug-slider-name { font-weight: 600; color: var(--muted); }
  .debug-slider-val { font-variant-numeric: tabular-nums; }
  .debug-slider input[type="range"] {
    width: 100%;
    margin: 0;
    accent-color: #3d6ea8;
  }
  .debug-reset {
    width: 100%;
    margin-top: 4px;
    padding: 5px 8px;
    font-size: 11px;
  }
  @media (max-width: 720px) {
    .debug-panel {
      right: 12px;
      left: auto;
      bottom: 72px;
      max-width: min(280px, calc(100vw - 24px));
    }
  }
