:root {
  --bg: #ffffff;
  --chrome: #f6f7f9;
  --chrome-2: #eceef2;
  --line: #dfe2e7;
  --text: #1f2328;
  --muted: #646b75;
  --faint: #9aa1ab;
  --accent: #2f6fde;
  --accent-ink: #ffffff;
  --accent-soft: #e6eefc;
  --desk: #e9ebef;
  --paper: #ffffff;
  --sel: rgba(160, 214, 80, 0.45);
  --drop: rgba(120, 200, 60, 0.55);
  --handle: #2f80ed;
  --menu-shadow: 0 10px 30px rgba(20, 24, 31, 0.16), 0 2px 6px rgba(20, 24, 31, 0.08);
  --radius: 8px;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17191d; --chrome: #1e2126; --chrome-2: #272b31; --line: #33373e;
    --text: #e7e9ec; --muted: #a2a8b1; --faint: #737a84; --accent: #6b9cf2; --accent-ink: #0d1117;
    --accent-soft: #24324a; --desk: #111317; --menu-shadow: 0 10px 30px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17191d; --chrome: #1e2126; --chrome-2: #272b31; --line: #33373e;
  --text: #e7e9ec; --muted: #a2a8b1; --faint: #737a84; --accent: #6b9cf2; --accent-ink: #0d1117;
  --accent-soft: #24324a; --desk: #111317; --menu-shadow: 0 10px 30px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--ui);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
kbd {
  font: 11px/1 ui-monospace, Menlo, Consolas, monospace;
  padding: 2px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  background: var(--chrome); color: var(--muted);
}

/* ---------------- Barra superior ---------------- */
.topbar {
  display: flex; align-items: center; gap: 4px;
  height: 48px; padding: 0 8px 0 10px;
  background: var(--chrome); border-bottom: 1px solid var(--line);
  flex: none; position: relative; z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 8px; padding-right: 10px; margin-right: 4px;
  color: var(--text); text-decoration: none; font-weight: 650; letter-spacing: -0.01em;
  border-right: 1px solid var(--line); height: 28px;
}
.brand svg { width: 26px; height: 26px; }
.tb-scroll { display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.tb-scroll::-webkit-scrollbar { display: none; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  height: 32px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent;
  color: var(--text);
}
.tb-btn + .tb-btn { box-shadow: -1px 0 0 var(--line); border-radius: 0 6px 6px 0; }
.tb-btn:hover:not(:disabled), .tb-btn[aria-expanded="true"] { background: var(--chrome-2); }
.tb-btn:disabled { color: var(--faint); cursor: default; }
.caret { width: 0; height: 0; border: 4px solid transparent; border-top-color: currentColor; margin-top: 4px; opacity: .7; }
.tb-right { display: flex; align-items: center; gap: 2px; flex: none; }
.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  border: 0; border-radius: 6px; background: transparent; color: var(--text);
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover:not(:disabled) { background: var(--chrome-2); }
.icon-btn:disabled { color: var(--faint); cursor: default; }
.btn-outline {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; margin: 0 4px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font-weight: 600;
}
.btn-outline svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-outline:hover { border-color: var(--faint); }
.btn-primary, .btn-ghost {
  height: 34px; padding: 0 16px; border-radius: 6px; font-weight: 600; white-space: nowrap;
}
.btn-primary { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); }
.btn-primary:disabled { opacity: .45; cursor: default; }
.btn-ghost { border: 1px solid var(--line); background: var(--bg); }
.btn-ghost:hover { background: var(--chrome); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------------- Menús ---------------- */
.menu {
  position: fixed; z-index: 50; display: none; min-width: 230px; max-width: calc(100vw - 16px);
  max-height: calc(100vh - 70px); overflow: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--menu-shadow); padding: 10px;
}
.menu.open { display: block; }
.menu-wide { width: 420px; }
.menu h3 { margin: 10px 4px 6px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.menu h3:first-child { margin-top: 2px; }
.opt { display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: 5px; cursor: pointer; }
.opt:hover { background: var(--chrome); }
.opt input { accent-color: var(--accent); margin: 0; }
#menuMore { padding: 6px; min-width: 250px; }
#menuMore button {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%;
  padding: 8px 10px; border: 0; background: none; border-radius: 5px; text-align: left;
}
#menuMore button:hover { background: var(--chrome); }
#menuMore hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.field small { font-weight: 400; }
.field-row { display: flex; gap: 8px; align-items: flex-end; }
.field-row .grow { flex: 1; }
input[type=text], input[type=number], select, textarea {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
}
textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.seg-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.seg-choice label { position: relative; cursor: pointer; }
.seg-choice input { position: absolute; opacity: 0; }
.seg-choice span { display: flex; flex-direction: column; gap: 2px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; height: 100%; }
.seg-choice small { color: var(--muted); font-size: 12px; }
.seg-choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.seg-choice input:focus-visible + span { outline: 2px solid var(--accent); }
.pass-status { margin: 8px 2px 0; font-size: 12px; color: var(--muted); }
.pass-status.err { color: #c2410c; }
.menu-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.toggle-row { display: flex; gap: 4px; }
.tog { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font-family: Georgia, serif; font-size: 15px; }
.tog.on { background: var(--accent-soft); border-color: var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 4px; }
.sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--bg); background: var(--c); box-shadow: 0 0 0 1px var(--line); padding: 0; }
.sw.on { box-shadow: 0 0 0 2px var(--accent); }
.sw-custom { position: relative; overflow: hidden; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); cursor: pointer; }
.sw-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.line-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.line-opts button { height: 30px; border: 1px solid transparent; border-radius: 5px; background: none; padding: 0 6px; }
.line-opts button:hover { background: var(--chrome); }
.line-opts button.on { border-color: var(--accent); background: var(--accent-soft); }
.line-opts svg { width: 100%; height: 10px; stroke: var(--text); stroke-linecap: round; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 4px 0; }

/* ---------------- Área de trabajo ---------------- */
.workspace { flex: 1; display: flex; min-height: 0; }
.palette {
  flex: none; width: var(--pal-w, 92px); padding: 6px; overflow-y: auto; overflow-x: hidden;
  display: grid; grid-template-columns: repeat(var(--pal-cols, 2), minmax(0, 1fr)); grid-auto-rows: 38px; gap: 2px; align-content: start;
  background: var(--chrome); border-right: 1px solid var(--line);
  scrollbar-width: thin;
}
.pal-btn {
  display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--text); padding: 0;
}
.pal-btn:hover { background: var(--chrome-2); }
.pal-btn.active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.pal-ico { width: 30px; height: 24px; overflow: visible; }
.pal-sep { grid-column: 1 / -1; height: 1px; background: var(--line); margin: 4px 2px; align-self: center; }

.stage { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--desk); }
.stage.no-page { background: var(--paper); }
.doc-head {
  flex: none; display: flex; align-items: center; gap: 4px; padding: 8px 16px 8px 20px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.doc-title {
  border: 0 !important; box-shadow: none !important; background: transparent !important;
  font-size: 18px; font-weight: 500; padding: 0 !important; height: 30px; width: auto; min-width: 120px; max-width: 70%;
  field-sizing: content;
}
.doc-head .icon-btn svg { width: 15px; height: 15px; stroke: none; }
#canvas { flex: 1; width: 100%; min-height: 0; touch-action: none; user-select: none; -webkit-user-select: none; cursor: default; }
.stage[data-tool="place"] #canvas, .stage[data-tool="line"] #canvas, .stage[data-tool="arrow"] #canvas,
.stage[data-tool="arrow2"] #canvas, .stage[data-tool="rect"] #canvas, .stage[data-tool="ellipse"] #canvas { cursor: crosshair; }
.stage[data-tool="text"] #canvas { cursor: text; }
.stage[data-tool="pen"] #canvas { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24'%3E%3Cpath d='M4 20l1.2-4.2L16 5l3 3L8.2 18.8z' fill='white' stroke='black' stroke-width='1.4'/%3E%3C/svg%3E") 2 20, crosshair; }
.stage.space #canvas { cursor: grab; }
.stage.panning #canvas { cursor: grabbing; }

/* Lienzo (SVG) */
.paper { fill: #ffffff; filter: url(#paperShadow); }
.margin { stroke: #8fd3ef; stroke-width: 1.2; }
.el .hit { fill: none; stroke: transparent; stroke-width: 14; stroke-linecap: round; pointer-events: stroke; }
.el .hit-r { fill: transparent; }
.el text { pointer-events: none; }
.shape:hover .hit { stroke: rgba(47, 128, 237, 0.10); }
.shape.sel .hit { stroke: var(--sel); }
.word { cursor: move; }
.word:hover .hit-r { fill: rgba(47, 128, 237, 0.08); }
.word.sel .hit-r { fill: var(--sel); }
.flow .flow-bg { fill: transparent; }
.flow.sel .flow-bg { fill: rgba(47, 128, 237, 0.04); }
.flow text[data-fi] { pointer-events: all; cursor: move; }
.flow text[data-fi]:hover { fill: var(--handle); }
.ph { font: italic 14px var(--ui); fill: #a6adb7; pointer-events: none; }
.h-move { fill: #ffffff; stroke: #4b5563; cursor: move; }
.h-size { fill: var(--handle); stroke: #ffffff; cursor: pointer; }
.h-move.small, .h-size.small { opacity: .8; }
.flow-edge { stroke: var(--handle); pointer-events: none; }
.flow-grip { fill: transparent; cursor: ew-resize; }
.marquee { fill: rgba(47, 128, 237, 0.08); stroke: var(--handle); stroke-dasharray: 4 3; pointer-events: none; }
.snap-guide { fill: none; stroke: #16a34a; pointer-events: none; }
.drop-hl { stroke: var(--drop); stroke-linecap: round; pointer-events: none; }
.drop-hl-pt { fill: var(--drop); pointer-events: none; }
.pen-preview { fill: none; stroke: #1f2328; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.ghost { opacity: .45; pointer-events: none; }

.inline-edit {
  position: absolute; z-index: 5; margin: 0; padding: 0 !important; min-width: 0;
  background: transparent !important; border: 0 !important; border-radius: 0; box-shadow: none !important;
  outline: none !important; caret-color: var(--handle); white-space: pre; overflow: visible;
}
.inline-edit::selection { background: rgba(47, 128, 237, 0.25); }
text.editing > tspan:not(.vn), text.editing:not(:has(tspan)) { fill-opacity: 0; }
.word.editing .hit-r { fill: transparent !important; }
.empty-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  max-width: 340px; text-align: center; color: var(--muted); pointer-events: none; padding: 16px;
}
.zoombar {
  position: absolute; right: 14px; bottom: 14px; display: flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.zoom-label { min-width: 52px; height: 30px; border: 0; background: none; font-variant-numeric: tabular-nums; font-size: 13px; border-radius: 5px; }
.zoom-label:hover { background: var(--chrome); }

#measure { position: absolute; left: -10000px; top: 0; width: 10px; height: 10px; visibility: hidden; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 100;
  background: #1f2328; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- Diálogos ---------------- */
.dlg {
  border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(480px, calc(100vw - 24px));
  background: var(--bg); color: var(--text); box-shadow: var(--menu-shadow);
}
.dlg-wide { width: min(880px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(15, 18, 24, .4); }
.dlg header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px 20px; }
.dlg h2 { margin: 0; font-size: 17px; }
.dlg footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.dlg .hint { margin: 0 20px 8px; }
.exp-body { display: grid; grid-template-columns: 1fr 220px; gap: 16px; padding: 0 20px 16px; }
.exp-preview {
  min-height: 240px; max-height: 52vh; overflow: auto; display: grid; place-items: center; padding: 16px;
  border-radius: 8px; border: 1px solid var(--line);
  background: repeating-conic-gradient(#f1f2f4 0 25%, #fafafb 0 50%) 0 0 / 16px 16px;
}
.exp-preview svg { max-width: 100%; height: auto; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.exp-opts h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 0 4px; }
.exp-opts h3:first-child { margin-top: 0; }
.doc-list { list-style: none; margin: 0; padding: 0 12px 12px; max-height: 55vh; overflow: auto; }
.doc-list li { display: flex; align-items: center; gap: 4px; border-radius: 8px; }
.doc-list li.current { background: var(--accent-soft); }
.doc-list li.empty { padding: 24px; color: var(--muted); justify-content: center; }
.doc-open { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px; border: 0; background: none; text-align: left; border-radius: 8px; }
.doc-open:hover { background: var(--chrome); }
.doc-open span { font-size: 12px; color: var(--muted); }
.help { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 0 20px 20px; max-height: 70vh; overflow: auto; }
.help h3 { font-size: 14px; margin: 14px 0 6px; }
.help h3:first-child { margin-top: 0; }
.help ol, .help ul { padding-left: 18px; margin: 0; }
.help li { margin: 5px 0; }
.help p { margin: 6px 0; }
.keys { border-collapse: collapse; width: 100%; font-size: 13px; }
.keys td { padding: 4px 6px 4px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.keys td:first-child { white-space: nowrap; }

/* ---------------- Pantallas pequeñas ---------------- */
@media (max-width: 720px) {
  .brand span, .btn-outline span { display: none; }
  .brand { padding-right: 6px; }
  .palette { width: 52px; grid-template-columns: 1fr; padding: 4px; }
  .doc-head { padding: 6px 10px; }
  .doc-title { font-size: 16px; }
  .exp-body, .help { grid-template-columns: 1fr; }
  .menu-wide { width: calc(100vw - 16px); }
  #btnDelete { display: none; }
}
@media (hover: none) {
  .shape:not(.sel):hover .hit { stroke: transparent; }
  .word:not(.sel):hover .hit-r { fill: transparent; }
}

/* ---------------- Modo oscuro del lienzo ---------------- */
.tb-div { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.dark .paper { fill: #23262c; filter: none; }
.dark .stage.no-page { background: #23262c; }
.dark .margin { stroke: #2f6a85; }
.dark #content [stroke="#1f2328"] { stroke: #e6e8eb; }
.dark #content [fill="#1f2328"] { fill: #e6e8eb; }
.dark #content [stroke="#6b7280"] { stroke: #a3a9b3; }
.dark #content [fill="#6b7280"] { fill: #a3a9b3; }
.dark .ghost [stroke="#1f2328"] { stroke: #e6e8eb; }
.dark .pen-preview { stroke: #e6e8eb; }
.dark .ph { fill: #6c737d; }
.dark .h-move { fill: #23262c; stroke: #c9ced6; }
.dark .h-size { stroke: #23262c; }
.dark #gridPat circle { fill: #3a3f47; }
.dark .exp-preview { background: repeating-conic-gradient(#2a2d33 0 25%, #24272c 0 50%) 0 0 / 16px 16px; }
.share-row { padding: 0 20px 4px; }
.share-row input { font-size: 13px; color: var(--muted); }
@media (max-width: 720px) { #btnShare { padding: 0 8px; } }

/* Botón destacado «Insertar pasaje» */
.tb-cta {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; flex: none;
  height: 32px; padding: 0 12px 0 10px; margin-right: 6px; border: 0; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
  box-shadow: 0 1px 2px rgba(20, 24, 31, .18), inset 0 -1px 0 rgba(0, 0, 0, .12);
  transition: filter .15s, transform .15s;
}
.tb-cta svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tb-cta:hover, .tb-cta[aria-expanded="true"] { filter: brightness(1.08); }
.tb-cta:active { transform: translateY(1px); }
.tb-cta + .tb-btn { box-shadow: none; }

/* Barras laterales: borde para arrastrar y botón para ocultar */
.sb-resizer {
  flex: none; width: 6px; margin-left: -3px; margin-right: -3px; position: relative; z-index: 4;
  cursor: col-resize; touch-action: none;
}
.sb-resizer::after { content: ""; position: absolute; inset: 0 2px; border-radius: 2px; transition: background .15s; }
.sb-resizer:hover::after, .sb-resizer:focus-visible::after, body.resizing .sb-resizer::after { background: var(--accent); }
.sb-toggle {
  position: absolute; top: 58px; width: 18px; height: 40px; padding: 0; display: grid; place-items: center;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line); cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .08); transition: color .15s, background .15s;
}
.sb-toggle:hover { color: var(--accent); background: var(--chrome); }
.sb-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.sb-left .sb-toggle { left: 3px; border-left: 0; border-radius: 0 7px 7px 0; }
.sb-right .sb-toggle { right: 3px; border-right: 0; border-radius: 7px 0 0 7px; }
.sb-right .sb-toggle svg { transform: rotate(180deg); }
body.pal-hidden .palette { display: none; }
body.pal-hidden .sb-left .sb-toggle svg { transform: rotate(180deg); }
body.side-hidden .stylebar { display: none; }
body.side-hidden .sb-right .sb-toggle svg { transform: none; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none; }
.pal-label { display: none; }
.palette.wide { grid-auto-rows: 36px; }
.palette.wide .pal-btn { display: flex; justify-content: flex-start; gap: 8px; padding: 0 8px; text-align: left; min-width: 0; }
.palette.wide .pal-ico { flex: none; }
.palette.wide .pal-label { display: block; font-size: 12px; line-height: 1.2; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette.wide .pal-btn.active .pal-label { color: var(--accent); }
@media (max-width: 720px) {
  .palette, .palette.wide { width: 52px; grid-template-columns: 1fr; }
  .palette.wide .pal-label { display: none; }
  .palette.wide .pal-btn { justify-content: center; padding: 0; }
  .sb-resizer { display: none; }
  body.pal-hidden .palette { display: grid; }
  body.side-hidden .stylebar { display: block; }
  .tb-cta { padding: 0 8px; }
  .tb-cta span { display: none; }
}

/* Menú contextual */
.ctx-menu { padding: 5px; min-width: 210px; }
.ctx-menu button {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; width: 100%;
  padding: 7px 10px; border: 0; background: none; border-radius: 5px; text-align: left;
}
.ctx-menu button:hover { background: var(--chrome); }
.ctx-menu button.danger { color: #c62828; }
.dark .ctx-menu button.danger { color: #ff8a80; }
.ctx-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 3px; }
@media (hover: none) { .ctx-menu button { padding: 11px 12px; } .ctx-menu kbd { display: none; } }
.grp-box { fill: none; stroke: var(--handle); stroke-dasharray: 5 4; opacity: .7; pointer-events: none; }
.dark .numbering text { fill: #a3a9b3; }
@media (max-width: 720px) {
  /* En el móvil, «Mis diagramas» y el modo oscuro están en el menú ⋮ */
  #btnDocs, #btnTheme, .tb-div { display: none; }
  .tb-right { gap: 0; }
  .tb-scroll { min-width: 90px; }
}

/* Barra lateral derecha: texto y línea */
.stylebar {
  flex: none; width: var(--side-w, 236px); overflow-y: auto; padding: 4px 14px 20px;
  background: var(--chrome); border-left: 1px solid var(--line); scrollbar-width: thin;
}
.side-sec { padding: 12px 0 14px; }
.side-sec + .side-sec { border-top: 1px solid var(--line); }
.side-sec h2 { margin: 0; font-size: 13px; font-weight: 650; }
.side-scope { margin: 2px 0 4px; font-size: 12px; color: var(--muted); }
.side-sec h3 { margin: 12px 0 6px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.side-sec .field { margin-top: 8px; }
.side-sec .field-row { align-items: flex-end; }
.side-sec .swatches { padding: 2px 0; }
.side-sec .line-opts button { background: var(--bg); border-color: var(--line); }
.side-sec .line-opts button.on { border-color: var(--accent); background: var(--accent-soft); }
#btnStyle { display: none; }
@media (max-width: 720px) {
  #btnStyle { display: inline-grid; }
  #btnClear { display: none; }
  .stylebar {
    position: fixed; right: 0; top: 48px; bottom: 0; z-index: 30; width: min(280px, 86vw);
    box-shadow: var(--menu-shadow); transform: translateX(105%); transition: transform .2s;
  }
  body.show-style .stylebar { transform: none; }
}
body.pal-hidden .sb-left { margin-left: 0; }
body.side-hidden .sb-right { margin-right: 0; }
