/* ── 106 Drawing style bar (.dsb-, static/js/drawing.js, 2026-11-20) ──────────
   The floating toolbar over a selected drawing, its popovers (colour, width
   and style, fill, text, fib levels, more) and its tooltip. Same surface as
   the chart's other floating pieces: --bg-elevated with an inset ring (never
   a 1px border, which bowties in screenshots) and --shadow-menu, as the
   right-click menu (.ctx-menu, 13-widgets.css); icons in the drawing rail's
   16-grid stroke style. The bar owns only .dsb-*. Positions (left / top /
   max-width) are set by drawing.js inside the price plot. */

.dsb,
.dsb-pop{
  position:absolute; z-index:45;
  background:var(--bg-elevated);
  border-radius:var(--radius-lg);
  box-shadow:inset 0 0 0 1px var(--border-default), var(--shadow-menu);
  user-select:none; -webkit-user-select:none; pointer-events:auto;
  font-family:var(--font-sans);
  touch-action:manipulation;
}
.dsb{
  display:flex; flex-wrap:wrap; align-items:center; gap:2px;
  padding:3px;
  box-sizing:border-box;
}
.dsb[hidden], .dsb-pop[hidden], .dsb-tip[hidden]{ display:none; }

.dsb-btn{
  position:relative;
  display:inline-flex; align-items:center; justify-content:center; gap:5px;
  min-width:28px; height:28px; padding:0 5px; box-sizing:border-box;
  border:0; border-radius:var(--radius-sm);
  background:transparent; color:var(--text-secondary); cursor:pointer;
  transition:background .12s var(--ease-out), color .12s var(--ease-out);
}
.dsb-btn svg{ flex:none; display:block; }
.dsb-btn:hover{ background:var(--bg-hover); color:var(--text-primary); }
.dsb-btn:focus{ outline:none; }
.dsb-btn:focus-visible{ box-shadow:inset 0 0 0 1.5px var(--accent); color:var(--text-primary); }
/* A popover's trigger reads as open; a toggle that is on reads as the rail's active tool. */
.dsb-btn.open{ background:var(--bg-hover); color:var(--text-primary); }
.dsb-btn[aria-pressed="true"]{ background:var(--accent-dim); color:var(--accent); }
.dsb-btn[aria-disabled="true"]{ opacity:.38; cursor:default; }
.dsb-btn[aria-disabled="true"]:hover{ background:transparent; color:var(--text-secondary); }
.dsb-btn[data-k="del"]:not([aria-disabled="true"]):hover{ background:var(--red-dim); color:var(--red); }

/* Colour triggers: the glyph sits up, the chosen colour is a bar under it. */
.dsb-swatchbtn svg{ margin-top:-5px; }
.dsb-chip{
  position:absolute; left:7px; right:7px; bottom:4px; height:3px;
  border-radius:1.5px;
  box-shadow:inset 0 0 0 0.5px color-mix(in srgb, var(--text-primary) 22%, transparent);
}
/* No fill: an empty outlined bar. */
.dsb-chip-none{ box-shadow:inset 0 0 0 1px var(--text-muted); }

/* Width and style trigger: the live line at its width and dash, then the px. */
.dsb-strokebtn{ padding:0 7px 0 6px; }
.dsb-px{ font:600 max(0.6875rem, var(--fs-floor))/1 var(--font-mono); color:inherit; letter-spacing:0.01em; }

.dsb-sep{ flex:none; width:1px; height:18px; margin:0 3px; background:var(--border-default); }

/* ── Popovers ── */
.dsb-pop{ display:flex; flex-direction:column; gap:6px; padding:6px; box-sizing:border-box; z-index:46; }
.dsb-grid{ display:grid; grid-template-columns:repeat(6, 24px); gap:5px; }
.dsb-sw{
  width:24px; height:24px; padding:0; border:0; cursor:pointer;
  border-radius:var(--radius);
  background:var(--sw);
  box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--text-primary) 14%, transparent);
  transition:box-shadow .12s var(--ease-out);
}
.dsb-sw:hover{ box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--text-primary) 14%, transparent), 0 0 0 2px var(--bg-elevated), 0 0 0 3px var(--text-muted); }
.dsb-sw[aria-pressed="true"]{ box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--text-primary) 14%, transparent), 0 0 0 2px var(--bg-elevated), 0 0 0 3.5px var(--text-primary); }
.dsb-sw:focus{ outline:none; }
.dsb-sw:focus-visible{ box-shadow:0 0 0 2px var(--bg-elevated), 0 0 0 3.5px var(--accent); }
/* "Default" is the drawing ink with a hollow centre, so it reads as "no
   colour chosen" rather than as one more blue. */
.dsb-sw-def{ background:radial-gradient(circle, var(--bg-elevated) 0 4px, var(--sw) 4.5px); }

.dsb-seg{ display:flex; gap:2px; padding:2px; border-radius:var(--radius); background:var(--bg-tertiary); }
.dsb-opt{
  flex:1 1 0; display:inline-flex; align-items:center; justify-content:center;
  min-width:30px; height:26px; padding:0 8px; box-sizing:border-box;
  border:0; border-radius:var(--radius-sm); cursor:pointer;
  background:transparent; color:var(--text-secondary);
  font:600 max(0.6875rem, var(--fs-floor))/1 var(--font-mono); letter-spacing:0.01em; white-space:nowrap;
  transition:background .12s var(--ease-out), color .12s var(--ease-out);
}
.dsb-opt:hover{ background:var(--bg-hover); color:var(--text-primary); }
.dsb-opt[aria-pressed="true"]{ background:var(--bg-elevated); color:var(--accent); box-shadow:inset 0 0 0 1px var(--border-default); }
.dsb-opt:focus{ outline:none; }
.dsb-opt:focus-visible{ box-shadow:inset 0 0 0 1.5px var(--accent); }
.dsb-widths .dsb-opt, .dsb-dashes .dsb-opt{ min-width:42px; }

.dsb-menu-item{
  display:flex; align-items:center; width:100%; min-width:10.5rem;
  padding:7px 10px; border:0; border-radius:var(--radius-sm); cursor:pointer;
  background:transparent; color:var(--text-secondary);
  font:inherit; font-size:.8rem; line-height:1.1; text-align:left; white-space:nowrap;
}
.dsb-menu-item:hover, .dsb-menu-item:focus-visible{ background:var(--bg-hover); color:var(--text-primary); outline:none; }
.dsb-menu-item:focus{ outline:none; }

/* Fib levels (was an inline-styled panel floating on its own). */
.dsb-levels{ gap:1px; min-width:8.5rem; padding:6px 6px 5px; }
.dsb-pop-head{ margin:1px 4px 4px; font-size:max(0.75rem, var(--fs-floor)); font-weight:500; color:var(--text-muted); }
.dsb-lv{
  display:flex; align-items:center; gap:7px; min-height:24px; padding:0 4px;
  border-radius:var(--radius-sm); cursor:pointer;
  font:600 max(0.6875rem, var(--fs-floor))/1 var(--font-mono); color:var(--text-primary);
}
.dsb-lv:hover{ background:var(--bg-hover); }
.dsb-lv input{ margin:0; width:13px; height:13px; cursor:pointer; }
.dsb-lv-sw{ flex:none; width:12px; height:3px; border-radius:1.5px; }

/* Tooltip in plain words: inverse ink, the chart's own small type. */
.dsb-tip{
  position:absolute; z-index:47; pointer-events:none;
  padding:4px 7px; border-radius:var(--radius-sm);
  background:var(--text-primary); color:var(--bg-primary);
  font:500 max(0.75rem, var(--fs-floor))/1.2 var(--font-sans); white-space:nowrap;
  box-shadow:var(--shadow-hairline);
}

/* ── Touch: 36 px targets, the bar wraps inside the plot (max-width from JS). ── */
:root.phone .dsb-btn{ min-width:36px; height:36px; }
:root.phone .dsb-chip{ left:10px; right:10px; bottom:6px; }
:root.phone .dsb-grid{ grid-template-columns:repeat(6, 36px); gap:4px; }
:root.phone .dsb-sw{ width:36px; height:36px; }
:root.phone .dsb-opt{ height:36px; min-width:36px; }
:root.phone .dsb-lv{ min-height:36px; }
:root.phone .dsb-lv input{ width:18px; height:18px; }
:root.phone .dsb-menu-item{ min-height:40px; font-size:15px; }
:root.phone .dsb-tip{ display:none; }
/* On a phone the bar may wrap to two rows: no separator to strand at a row start. */
:root.phone .dsb-sep{ display:none; }
:root.phone .dsb{ gap:3px; }
@media (pointer:coarse){
  .dsb-btn{ min-width:36px; height:36px; }
  .dsb-chip{ left:10px; right:10px; bottom:6px; }
  .dsb-grid{ grid-template-columns:repeat(6, 36px); gap:4px; }
  .dsb-sw{ width:36px; height:36px; }
  .dsb-opt{ height:36px; min-width:36px; }
  .dsb-lv{ min-height:36px; }
}
@media (prefers-reduced-motion:reduce){
  .dsb-btn, .dsb-sw, .dsb-opt{ transition:none; }
}
