.app { position: fixed; inset: 0; display: grid; grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w); grid-template-rows: minmax(0, 1fr); }
.stage { position: relative; min-width: 0; overflow: hidden; background: var(--canvas); }
#gc { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: default; outline-offset: -4px; }
#gc[data-pointer]:focus-visible { outline: none; }
#gc.grab { cursor: grab; } #gc.grabbing { cursor: grabbing; } #gc.pointer { cursor: pointer; } #gc.link { cursor: crosshair; } #gc.move { cursor: move; }

.panel { background: var(--panel); display: flex; flex-direction: column; min-height: 0; position: relative; z-index: 3; }
.panel-left { border-right: 1px solid var(--region); box-shadow: 2px 0 14px rgb(0 0 0 / .12); }
.panel-right { border-left: 1px solid var(--region); box-shadow: -2px 0 14px rgb(0 0 0 / .12); }
.panel::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad); z-index: 1; }
.panel { max-height: 100dvh; }
.panel-body { --pb: calc(28px + env(safe-area-inset-bottom)); flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 4px 18px var(--pb); scroll-padding-bottom: 32px; scrollbar-width: thin; }
.sheet-head { display: none; }

.toolbar {
  position: absolute; z-index: 2; top: 14px; left: 14px; right: 14px; display: flex; align-items: center; gap: 6px;
  pointer-events: none;
}
.toolbar > * { pointer-events: auto; }
.toolbar .tool { flex: none; } /* the search box gives way, never the buttons */
@media (pointer: coarse) { .toolbar .tool, .zoomer .tool { min-width: var(--tap); min-height: var(--tap); } }
.toolbar .tool, .zoomer .tool { background: var(--panel); border-color: var(--line); box-shadow: var(--shadow); }
.search { position: relative; flex: 0 1 340px; min-width: 0; display: flex; align-items: center; }
.search > svg { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.searchbox {
  width: 100%; height: 40px; padding: 0 12px 0 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); box-shadow: var(--shadow); color: var(--ink);
}
.searchbox:focus-visible { outline-offset: 0; border-color: var(--focus); }
.toolbar .conn.tiny { margin-left: auto; padding: 0 4px; }

.zoomer {
  position: absolute; z-index: 2; right: 14px; bottom: 14px; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.fit-label { display: none; }
.viewnote {
  position: absolute; z-index: 2; left: 14px; bottom: 14px; max-width: min(420px, calc(100% - 96px)); padding: 8px 12px;
  font: 600 12px/1.4 var(--f-ui); color: var(--ink); background: var(--panel); border: 1px solid var(--a); border-radius: 10px; box-shadow: var(--shadow);
  pointer-events: none;
}
.zoom-pct { font: 600 11px var(--f-mono); color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; }

.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; pointer-events: none; gap: 8px; }
.empty h2 { font: italic 600 28px var(--f-display); }
.empty p { max-width: 38ch; color: var(--muted); }
.banner {
  position: absolute; z-index: 5; left: 50%; top: 66px; transform: translateX(-50%); width: min(520px, calc(100% - 28px));
  display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--bad); border-radius: var(--r-m); box-shadow: var(--shadow); color: var(--bad);
}
.tabbar { display: none; }

@media (max-width: 1180px) { :root { --left-w: 264px; --right-w: 296px; } }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .stage { position: fixed; inset: 0 0 calc(var(--tab-h) + env(safe-area-inset-bottom)) 0; }
  .tabbar {
    display: grid; grid-template-columns: 1fr 1fr; position: fixed; z-index: 6; left: 0; right: 0; bottom: 0;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--panel); border-top: 1px solid var(--region);
  }
  .tab { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); border: 0; background: none; font-weight: 600; color: var(--muted); cursor: pointer; }
  .tab[aria-expanded="true"] { color: var(--ink); box-shadow: inset 0 3px 0 var(--b); }
  .panel {
    position: fixed; z-index: 5; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); max-height: 58vh; max-height: min(58dvh, calc(100dvh - var(--tab-h) - env(safe-area-inset-bottom) - 72px));
    border: 1px solid var(--region); border-bottom: 0; border-radius: 20px 20px 0 0; box-shadow: 0 -12px 40px rgb(0 0 0 / .25);
    transform: translateY(110%); visibility: hidden; transition: transform .28s var(--ease), visibility 0s .28s;
  }
  .panel::before { border-radius: 20px 20px 0 0; }
  .panel.open { transform: none; visibility: visible; transition: transform .28s var(--ease), visibility 0s; }
  .sheet-head { display: flex; justify-content: center; align-items: flex-start; position: relative; padding: 10px 0 0; min-height: 52px; }
  .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); }
  .sheet-close { position: absolute; right: 8px; top: 6px; width: var(--tap); height: var(--tap); }
  .brandcard { margin-top: 0; padding: 8px 12px; } .brandcard img { max-width: 150px; }
  .zoomer { bottom: 10px; right: 10px; }
  .viewnote { left: 10px; bottom: 10px; max-width: calc(100% - 120px); }
  .zoomer .tool { width: var(--tap); height: var(--tap); }
  .zoomer #fitBtn { display: inline-flex; align-items: center; width: auto; padding: 0 12px; gap: 6px; font-weight: 700; font-size: 14px; } .fit-label { display: inline; }
  .toolbar { top: 10px; left: 10px; right: 10px; }
  .toolbar .tool { width: var(--tap); height: var(--tap); }
  .searchbox { height: var(--tap); }
}
