  /* ---- Edit layout and the Appearance editor ---- */
  .edit-hidden { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
  .edit-hidden[hidden] { display: none; }
  #editHiddenList { display: inline-flex; flex-wrap: wrap; gap: 4px; }
  /* Edit mode: tools on each section and entry, a line where a dragged one lands, the edges, the bar. */
  .edit-tools { display: none; }
  body.layout-editing .edit-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 6px 0 10px; }
  body.layout-editing #todayPanel .tp-section { position: relative; }
  body.layout-editing #todayPanel .tp-section > .tp-label { padding-right: 40px; }
  #todayPanel .edit-tools .edit-gear { position: absolute; top: 6px; right: 0; }
  body.layout-editing #moduleNav > .edit-tools { margin: 2px 12px 10px; }
  body.layout-editing #todayPanel .tp-section, body.layout-editing #projectNav > .pj-domain { outline: var(--bw) dashed var(--line); outline-offset: 3px; }
  body.layout-editing #projectNav > .pj-domain > .edit-tools { margin: 2px 16px 10px; }
  body.layout-editing #projectsPage { padding-bottom: var(--edit-room, 280px); } /* the last domain card clear of the bar */
  .edit-grip { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 32px; border: var(--bw) var(--bs) var(--line); border-radius: var(--r-xs); color: var(--ink-soft); font-size: 16px; line-height: 1; }
  .edit-btn { min-height: 32px; min-width: 32px; padding: 2px 7px; font-size: 12px; }
  /* a pinned section's Up, Down, grip and Minimize: dimmed, still pressable, to say why they don't move it */
  .edit-btn[aria-disabled="true"], .edit-grip.edit-held { opacity: .5; cursor: default; }
  .dragging { opacity: .55; }
  .drop-before { box-shadow: 0 -3px 0 0 var(--accent); }
  .drop-after { box-shadow: 0 3px 0 0 var(--accent); }
  #todayPanel .tp-section.tp-folded > :not(.tp-label):not(.edit-tools), #todayPanel .tp-slot.tp-folded > :not(.tp-label) { display: none !important; }
  #todayPanel .tp-folded .tp-label { margin-bottom: 0; }
  #todayPanel .tp-label.foldable { cursor: pointer; }
  #editBar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 40; width: 540px; max-width: calc(100vw - 24px); box-sizing: border-box; background: var(--card); color: var(--ink); border: var(--bw) var(--bs) var(--line); border-radius: var(--r-xs); box-shadow: var(--shadow-panel); padding: 12px 16px; }
  #editBar h2 { font-size: 15px; margin: 0 0 4px; }
  /* room under the last section for the Edit layout bar (its height, measured by syncEditRoom), so
     the bottom section and its gear scroll clear of it. */
  body.layout-editing #todayPanel, body.layout-editing #rail .nav { padding-bottom: var(--edit-room, 280px) !important; } /* over each width's own padding */
  /* the keyboard's button scrolls clear of the bar too (Tab, or Up and Down moving a section to the bottom) */
  body.layout-editing #todayPanel, body.layout-editing #scroller { scroll-padding-bottom: var(--edit-room, 280px); }
  /* the edit bar's tabs, and the Appearance sheet beside the page */
  .edit-tabs { display: flex; gap: 4px; margin: 0 0 8px; border-bottom: var(--bw) var(--bs) var(--line); }
  .edit-tabs [role="tab"] { background: transparent; border: 0; border-bottom: var(--bw-thick) var(--bs) transparent; color: var(--ink-soft); font: inherit; font-size: 13.5px; padding: 6px 10px; margin-bottom: calc(-1 * var(--bw)); }
  .edit-tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
  /* the editor sits beside the preview page in the main area (above it on a phone) */
  body.appearance-editing #main > :not(#topbar):not(#apWrap) { display: none; }
  #apWrap { flex: 1; min-height: 0; display: flex; }
  #apWrap[hidden] { display: none; }
  #themePreview { flex: 1; min-width: 0; overflow-y: auto; background-image: var(--bg-main, none); background-size: cover; background-position: center; }
  #themePreview .tpv-inner { max-width: 760px; margin: 0 auto; padding: 28px 28px 180px; }
  .tpv-title { font-family: var(--display); font-weight: 500; font-size: 34px; line-height: 1.15; margin: 8px 0 6px; color: var(--ink); text-shadow: var(--heading-shadow); }
  .tpv-lede { color: var(--ink-soft); margin: 0 0 24px; }
  .tpv-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 0 0 16px; }
  .tpv-card { background: var(--card); border: var(--bw) var(--bs) var(--line); border-radius: var(--r-md); padding: 12px 14px; box-shadow: var(--shadow-field); }
  .tpv-card-name { font-family: var(--display); font-size: 18px; color: var(--ink); }
  .tpv-card input[type="text"] { width: 100%; }
  .tpv-ok { color: var(--ok-text); background: var(--ok-bg); border: var(--bw) var(--bs) var(--ok-line); border-radius: var(--r-sm); padding: 8px 10px; }
  .tpv-danger { color: var(--danger); background: var(--danger-bg); border: var(--bw) var(--bs) var(--danger-border); border-radius: var(--r-sm); padding: 8px 10px; }
  .tpv-dialog { background: var(--paper); color: var(--ink); border: var(--bw) var(--bs) var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--titlebar-paper), var(--shadow-dialog); padding: 18px 16px 14px; margin: 18px 0; max-width: 420px; }
  .tpv-dialog-head { font-family: var(--display); font-size: 17px; margin: 0 0 6px; }
  .tpv-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .tpv-panel { background-color: var(--rail); background-size: cover; background-position: center; border: var(--bw) var(--bs) var(--line); border-radius: var(--r-md); box-shadow: var(--titlebar-rail); padding: 18px 12px 12px; min-height: 140px; }
  .tpv-panel.left { background-image: var(--bg-left, none); } .tpv-panel.right { background-image: var(--bg-right, none); }
  .tpv-panel-label { font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-text); margin: 0 0 8px; }
  .tpv-item { padding: 6px 8px; border-radius: var(--r-sm); color: var(--ink); }
  .tpv-item.active { background: var(--rail-active); }
  /* the rest of the samples, and the outline on what you're editing */
  .tpv-banner { background: var(--card); color: var(--ink); border: var(--bw) var(--bs) var(--line); border-left: var(--bw-thick) var(--bs) var(--deco); border-radius: var(--r-md); padding: 10px 14px; margin: 0 0 16px; }
  .tpv-pointed-row { margin: 0 0 16px; }
  .tpv-pointed.btn-primary { background: var(--accent-hover); }
  .tpv-pointed.btn-secondary { background: var(--card-hover); border-color: var(--line-strong); }
  .tpv-here { white-space: nowrap; margin-left: 6px; }
  .tpv-badge { color: var(--on-danger); background: var(--danger); border-radius: var(--r-xs); padding: 1px 6px; font-weight: 600; margin-left: 6px; }
  .tpv-tabs { display: flex; gap: 6px; align-items: center; margin: 0 0 8px; }
  .tpv-tabs .group-tab { display: inline-grid; place-items: center; box-sizing: border-box; cursor: default; }
  .tpv-scroll { height: 70px; overflow-y: auto; margin: 16px 0 0; padding: 4px 12px; background: var(--card); color: var(--ink); border: var(--bw) var(--bs) var(--line); border-radius: var(--r-md); scrollbar-color: var(--scroll-thumb) var(--scroll-track); }
  .tpv-lit-line { position: sticky; top: 0; z-index: 2; margin: 0; padding: 6px 12px; font-size: 12.5px; background: var(--paper); color: var(--ink); border-bottom: var(--bw) var(--bs) var(--line-strong); }
  #themePreview .tpv-lit { outline: 3px dashed var(--ink); outline-offset: 3px; }
  #themePreview.tpv-lit { outline: 3px dashed var(--ink); outline-offset: -5px; }
  @media (prefers-reduced-motion: no-preference) { #themePreview .tpv-lit { animation: tpvLit 1.2s ease-in-out 2; } @keyframes tpvLit { 50% { outline-color: var(--accent); } } }
  #apSheet { flex: none; width: 380px; max-width: 100%; box-sizing: border-box; overflow-y: auto; background: var(--paper); color: var(--ink); border-left: var(--bw) var(--bs) var(--line-strong); padding: 18px 18px 180px; }
  #apSheet label { display: block; margin-top: 8px; }
  #apSheet input[type="text"], #apSheet select { width: 100%; }
  #apSheet .ap-group { border: var(--bw) var(--bs) var(--line); border-radius: var(--r-md); margin: 12px 0 0; padding: 4px 12px 12px; }
  #apSheet .ap-group legend { font-weight: 600; padding: 0 4px; }
  #apSheet .ap-colour { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
  #apSheet .ap-colour label { margin: 0; flex: 1; }
  #apSheet .ap-colour input[type="color"] { width: 44px; height: 30px; padding: 0; border: var(--bw) var(--bs) var(--field-border); border-radius: var(--r-sm); background: var(--card); flex: none; }
  #apSheet .ap-thumb { display: block; width: 100%; max-height: 80px; object-fit: cover; border-radius: var(--r-sm); border: var(--bw) var(--bs) var(--line); margin-top: 6px; }
  #apSheet input[type="range"] { width: 100%; }
  @media (max-width: 760px) { #apWrap { flex-direction: column; } #themePreview { flex: none; height: 45%; border-bottom: var(--bw-thick) var(--bs) var(--line-strong); } #themePreview .tpv-inner { padding: 16px 16px 24px; } #apSheet { width: auto; flex: 1; border-left: 0; } }
  #apSheet .ap-more { margin: 12px 0 0; } #apSheet .ap-more > summary { font-weight: 600; cursor: pointer; }
  #apSheet .ap-what { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
  #editBar .edit-state { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 8px; }
  @media (max-width: 820px) {
    #editBar { bottom: calc(var(--places-h, 60px) + env(safe-area-inset-bottom) + 10px); }
  }
