/* Change only the local plot, leaving the chart grid, rails and watchlist alone. */
.plot:is([data-depth-placement=left], [data-depth-placement=right]) {
  --depth-dock-width: clamp(306px, 39%, 408px);
}
.plot[data-depth-placement=left] {
  --depth-chart-column: 2;
  --depth-book-column: 1;
  grid-template-columns: var(--depth-dock-width) minmax(0, 1fr);
}
.plot[data-depth-placement=right] {
  --depth-chart-column: 1;
  --depth-book-column: 2;
  grid-template-columns: minmax(0, 1fr) var(--depth-dock-width);
}
.plot:is([data-depth-placement=left], [data-depth-placement=right]) > :is(.legend, .canvas-box, .chart-foot) {
  grid-column: var(--depth-chart-column) / span 1;
}
.plot:is([data-depth-placement=left], [data-depth-placement=right]) > #panel-body {
  grid-column: var(--depth-book-column);
  grid-row: 1 / -1;
}
.plot[data-depth-placement=left] > #panel-body { border-inline-end: 2px solid var(--base); }
.plot[data-depth-placement=right] > #panel-body { border-inline-start: 2px solid var(--base); }
:root[data-theme=dark] .plot[data-depth-placement=left] > #panel-body { border-inline-end-color: var(--line); }
:root[data-theme=dark] .plot[data-depth-placement=right] > #panel-body { border-inline-start-color: var(--line); }

.plot:is([data-depth-placement=left], [data-depth-placement=right], [data-depth-placement=float]) > #panel-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: none;
  overflow: hidden;
  border-top: 0;
  background: var(--surface);
}
.plot:is([data-depth-placement=left], [data-depth-placement=right], [data-depth-placement=float]) > #panel-body > #panel-content {
  min-height: 0;
  overscroll-behavior: contain;
}
.plot[data-depth-placement=bottom] > #panel-body {
  display: flex;
  flex-direction: column;
  max-height: min(48dvh, 380px);
}
.plot[data-depth-placement] > #panel-body > #panel-content:has(.depth-book) {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.plot[data-depth-placement] #panel-tools { flex: none; max-height: 35%; overflow: auto; }
.plot[data-depth-placement=bottom] .depth-note { display: none; }
.plot[data-depth-placement=float] { position: relative; }
.plot[data-depth-placement=float] > #panel-body {
  position: absolute;
  left: var(--depth-float-x);
  top: var(--depth-float-y);
  width: var(--depth-float-width);
  height: var(--depth-float-height);
  z-index: 6;
  padding-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 3px 14px color-mix(in oklch, var(--ink) 18%, transparent);
}
:root[data-theme=dark] .plot[data-depth-placement=float] > #panel-body {
  box-shadow: 0 3px 14px color-mix(in oklch, var(--base) 72%, transparent);
}

.plot[data-depth-placement] > #panel-body > .panel-header { gap: 3px; }
.plot[data-depth-placement] > #panel-body > .panel-header > h2 {
  margin-inline-end: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel-header > .depth-placement-toggle {
  flex: none;
  min-height: 28px;
  padding-inline: 6px;
  font-size: .85rem;
  color: var(--muted);
}
.depth-placement-move, .depth-placement-size {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  color: var(--muted);
  touch-action: none;
  user-select: none;
}
.depth-placement-move { cursor: grab; margin-inline-start: -6px; }
.plot[data-depth-placement=float] .panel-header { cursor: grab; touch-action: none; user-select: none; }
.depth-placement-popup { cursor: auto; user-select: text; }
.depth-placement-size { position: absolute; bottom: 0; right: 0; cursor: nwse-resize; }
.depth-placement-move:hover, .depth-placement-size:hover { background: var(--soft); }
#panel-body[data-depth-gesture=move] .depth-placement-move { cursor: grabbing; }
.depth-placement-move svg, .depth-placement-size svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  pointer-events: none;
}

.depth-placement-popup {
  position: fixed;
  inset: 8px auto auto 8px;
  margin: 0;
  width: min(256px, calc(100% - 16px));
  max-height: calc(100dvh - 16px);
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: .9rem;
  overflow: auto;
  overscroll-behavior: contain;
}
.depth-placement-choice { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.depth-placement-choice select { min-width: 0; padding: 4px 6px; border: 1px solid var(--line); }
.depth-placement-status { color: var(--muted); margin: 6px 0 0; }
.depth-placement-geometry {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 8px;
  min-width: 0;
  margin: 8px 0 0;
  padding: 4px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.depth-placement-geometry legend { color: var(--muted); }
.depth-placement-geometry label { display: grid; gap: 2px; min-width: 0; }
.depth-placement-popup input { width: 100%; padding: 3px 5px; font-variant-numeric: tabular-nums; }
.depth-placement-popup .depth-placement-reset { margin-top: 7px; padding-inline: 6px; color: var(--muted); }

@media (any-pointer: coarse) {
  .panel-header > .depth-placement-toggle { min-height: 34px; }
  .depth-placement-move, .depth-placement-size { width: 30px; height: 30px; }
  .plot[data-depth-placement=float] > #panel-body { padding-bottom: 30px; }
}
