:root {
  --bg: #1b1e24;
  --panel: #232831;
  --panel-2: #2b313c;
  --line: #374050;
  --text: #e6e9ef;
  --dim: #8d97a8;
  --accent: #4f8cff;
  --accent-2: #3a6fd8;
  --danger: #ef5350;
  --sel: #4f8cff;
  --viewer-bg: #3a3f4a;
  --hover: #343b48;
  --field: #171a20;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
}
body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font:
    13px/1.35 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  overflow: hidden;
  user-select: none;
}
.hidden {
  display: none !important;
}
.dim {
  color: var(--dim);
}
.small {
  font-size: 12px;
}
.spacer {
  flex: 1;
}

/* top bars */
#topbar,
#toolbar,
#propsbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
#toolbar {
  padding: 5px 10px;
}
#propsbar {
  min-height: 40px;
  background: var(--panel-2);
  gap: 14px;
  flex-wrap: wrap;
}
.group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.sep {
  width: 1px;
  height: 24px;
  background: var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
  font-weight: 600;
}
.logo {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 5px;
  letter-spacing: 0.5px;
}
.logo.big {
  font-size: 22px;
  padding: 8px 14px;
  border-radius: 10px;
  display: inline-block;
}
.label {
  color: var(--dim);
  padding: 0 4px;
  min-width: 38px;
  text-align: center;
}
.doc-name {
  color: var(--dim);
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
}
.btn:hover:not(:disabled) {
  background: var(--hover);
}
.btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.btn.icon {
  width: 32px;
  padding: 0;
}
.btn.primary {
  background: var(--accent);
  color: #fff;
}
.btn.primary:hover:not(:disabled) {
  background: var(--accent-2);
}
.btn.large {
  height: 40px;
  padding: 0 22px;
  font-size: 15px;
}
.btn.active {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border-color: var(--accent);
  color: var(--text);
}
.btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn.tool {
  width: 36px;
  height: 34px;
  padding: 0;
}

input.num,
#propsbar input[type='number'],
#propsbar select,
.modal input[type='text'],
.modal select {
  height: 28px;
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 6px;
  font: inherit;
  user-select: text;
}
input.num {
  width: 56px;
}
#propsbar input[type='color'] {
  width: 30px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  background: none;
  border-radius: 4px;
  cursor: pointer;
}
#propsbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--dim);
}
#propsbar input[type='range'] {
  width: 90px;
}
#propsbar .toggle {
  width: 30px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--field);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
#propsbar .toggle.on {
  background: rgba(79, 140, 255, 0.28);
  border-color: var(--accent);
}
#propsbar .hint {
  color: var(--dim);
}

/* main layout */
#main {
  flex: 1;
  display: flex;
  min-height: 0;
}
#sidebar {
  width: 168px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  flex: none;
}
#thumbs {
  padding: 10px 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.thumb {
  width: 128px;
  text-align: center;
  cursor: pointer;
  padding: 5px;
  border-radius: 7px;
  border: 2px solid transparent;
  position: relative;
}
.thumb:hover {
  background: var(--hover);
}
.thumb.current {
  border-color: var(--accent);
  background: rgba(79, 140, 255, 0.12);
}
.thumb.picked {
  background: rgba(79, 140, 255, 0.28);
}
.thumb canvas {
  display: block;
  margin: 0 auto 4px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.thumb .num {
  font-size: 11px;
  color: var(--dim);
}
.thumb.dragover-before::before,
.thumb.dragover-after::after {
  content: '';
  position: absolute;
  left: 6px;
  right: 6px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}
.thumb.dragover-before::before {
  top: -7px;
}
.thumb.dragover-after::after {
  bottom: -7px;
}

#viewer {
  flex: 1;
  position: relative;
  overflow: auto;
  background: var(--viewer-bg);
}
#pages {
  padding: 20px 0 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  min-width: min-content;
}

.page {
  position: relative;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  flex: none;
}
.page canvas {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}
.text-layer,
.ann-layer,
.form-layer {
  position: absolute;
  inset: 0;
}
.ann-layer {
  z-index: 3;
}
.form-layer {
  z-index: 2;
}
.text-layer {
  z-index: 4;
  pointer-events: none;
}
body.tool-edittext .text-layer {
  pointer-events: auto;
}
.tl {
  position: absolute;
  border-radius: 2px;
  cursor: text;
}
.tl:hover {
  background: rgba(79, 140, 255, 0.18);
  outline: 1px solid rgba(79, 140, 255, 0.9);
}

body.tool-select .ann-layer {
  cursor: default;
}
body:not(.tool-select):not(.tool-edittext) .ann-layer {
  cursor: crosshair;
}
body.tool-text .ann-layer {
  cursor: text;
}
body:not(.tool-select) .ann > * {
  pointer-events: none;
}
body.tool-edittext .ann-layer {
  pointer-events: none;
}
body.tool-edittext .ann {
  pointer-events: none;
}

.cover {
  position: absolute;
  pointer-events: none;
}
.ann {
  position: absolute;
}
.ann.selected {
  outline: 1.5px solid var(--sel);
  outline-offset: 1px;
}
.ann.text-ann {
  white-space: pre;
  line-height: 1.2;
  cursor: move;
  min-width: 4px;
  min-height: 1em;
  padding: 0;
  margin: 0;
}
.ann.text-ann[contenteditable='plaintext-only'],
.ann.text-ann.editing {
  cursor: text;
  outline: 1.5px dashed var(--sel);
  outline-offset: 1px;
  background: rgba(255, 255, 255, 0.55);
  user-select: text;
}
.ann img {
  width: 100%;
  height: 100%;
  display: block;
  -webkit-user-drag: none;
}
.ann svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  display: block;
}
.ann.shape {
  cursor: move;
}
.handle {
  user-select: none;
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 1.5px solid var(--sel);
  border-radius: 2px;
  z-index: 6;
}
.handle.nw {
  left: -6px;
  top: -6px;
  cursor: nwse-resize;
}
.handle.ne {
  right: -6px;
  top: -6px;
  cursor: nesw-resize;
}
.handle.sw {
  left: -6px;
  bottom: -6px;
  cursor: nesw-resize;
}
.handle.se {
  right: -6px;
  bottom: -6px;
  cursor: nwse-resize;
}

.form-layer input[type='text'],
.form-layer textarea,
.form-layer select {
  position: absolute;
  background: rgba(79, 140, 255, 0.13);
  border: 1px solid rgba(79, 140, 255, 0.65);
  border-radius: 2px;
  padding: 0 3px;
  margin: 0;
  font-family: Helvetica, Arial, sans-serif;
  color: #111;
  user-select: text;
  outline: none;
}
.form-layer textarea {
  resize: none;
  padding: 2px 3px;
}
.form-layer input:focus,
.form-layer textarea:focus,
.form-layer select:focus {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(79, 140, 255, 0.4);
}
.form-layer input[type='checkbox'],
.form-layer input[type='radio'] {
  position: absolute;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
body.tool-edittext .form-layer,
body:not(.tool-select) .form-layer {
  pointer-events: none;
}

/* welcome */
#welcome {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--viewer-bg);
}
.welcome-card {
  text-align: center;
  max-width: 440px;
  padding: 36px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.welcome-card h1 {
  margin: 14px 0 6px;
  font-size: 26px;
}
.welcome-card p {
  color: var(--dim);
  margin: 6px 0 20px;
  font-size: 14px;
}
body.dragging #welcome .welcome-card,
body.dragging #viewer {
  outline: 3px dashed var(--accent);
  outline-offset: -8px;
}

#statusbar {
  display: flex;
  gap: 12px;
  padding: 4px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
  background: #0e1014;
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  z-index: 50;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  max-width: 70vw;
}
.toast.error {
  border-color: var(--danger);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  min-width: 380px;
  max-width: 92vw;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.modal-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
}
.modal-card .row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}
.modal-card .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.modal-card canvas.pad {
  background: #fff;
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
  display: block;
}
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}
.tabs .btn {
  border: 1px solid var(--line);
}
.sig-saved {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sig-saved .sig {
  background: #fff;
  border-radius: 6px;
  padding: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
}
.sig-saved .sig:hover {
  border-color: var(--accent);
}
.sig-saved .sig img {
  height: 44px;
  display: block;
}

/* ---- tools hub ---- */
.hub {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 30;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.hub.hidden,
.hidden {
  display: none !important;
}
.hub-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px 8px;
}
.hub-head h2 {
  margin: 0 0 2px;
  font-size: 22px;
}
.hub-head > div {
  flex: 1;
}
.hub-search {
  width: 260px;
  height: 34px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 0 12px;
}
.hub-tabs .tab {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
}
.hub-tabs .tab.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  align-content: start;
}
.tcard {
  position: relative;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition:
    transform 0.08s,
    border-color 0.08s;
  font: inherit;
}
.tcard:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.ticon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ticon svg {
  width: 24px;
  height: 24px;
}
.tname {
  font-weight: 600;
  font-size: 15px;
}
.tdesc {
  color: var(--dim);
  font-size: 12.5px;
  line-height: 1.4;
}

.tool-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tool-body {
  overflow: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.trow {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.tfield {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--dim);
  flex: 1;
  min-width: 120px;
}
.tfield input,
.tfield select,
.tfield textarea,
.tool-body textarea,
.tool-body input[type='text'],
.tool-body input[type='password'],
.tool-body input[type='number'],
.tool-body select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
}
.tcheck {
  font-size: 13px;
  display: block;
}
.tlabel {
  font-size: 12.5px;
  color: var(--dim);
  margin-bottom: 4px;
}
.tfiles {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tfile {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  flex-wrap: wrap;
}
.tfile .grow {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}
.tfile.out {
  border-color: #2f7d4f;
}
.tmsg {
  white-space: pre-wrap;
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 13px;
}
.tmsg.error {
  border-color: var(--danger);
}
.tresults {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tprogress {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tbar {
  height: 6px;
  background: var(--accent);
  border-radius: 3px;
  width: 0;
  transition: width 0.15s;
}
.tdiff {
  max-height: 280px;
  overflow: auto;
  background: #fff;
  color: #111;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
}
.tdiff h4 {
  margin: 8px 0 2px;
}
.tdiff .dbody {
  white-space: pre-wrap;
}
.tdiff .del {
  background: #ffd7d7;
  text-decoration: line-through;
}
.tdiff .add {
  background: #c9f1d2;
}
.tvideo {
  width: 100%;
  max-height: 240px;
  background: #000;
  border-radius: 8px;
}
.tstrip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tshot {
  position: relative;
}
.tshot img {
  height: 90px;
  border-radius: 4px;
  display: block;
}
.tshot .btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
}
.tkey {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dim.small,
.small {
  font-size: 12px;
}

/* ---- light theme, accent, density ---- */
:root[data-theme='light'] {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --panel-2: #eceff5;
  --line: #d3d9e4;
  --text: #1b2230;
  --dim: #5d6779;
  --viewer-bg: #cdd3dd;
  --danger: #d93a36;
  --hover: #e1e6ee;
  --field: #ffffff;
  color-scheme: light;
}
:root[data-theme='dark'] {
  color-scheme: dark;
}
:root[data-density='compact'] .tcard {
  padding: 10px 12px;
  gap: 3px;
}
:root[data-density='compact'] .tdesc {
  display: none;
}
:root[data-density='compact'] .hub-grid {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

/* ---- hub shell ---- */
.hub-body {
  flex: 1;
  display: flex;
  min-height: 0;
}
.hub-side {
  width: 220px;
  flex: none;
  overflow: auto;
  padding: 4px 10px 20px 20px;
  border-right: 1px solid var(--line);
}
.side-h {
  margin: 14px 8px 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}
.hub-side .tab {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: 0;
  color: var(--text);
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.hub-side .tab:hover {
  background: var(--panel-2);
}
.hub-side .tab.on {
  background: var(--accent);
  color: #fff;
}
.hub-side .cnt {
  font-size: 11px;
  opacity: 0.65;
}
.hub-main {
  flex: 1;
  overflow: auto;
  padding: 8px 28px 32px;
}
.hub-grid.inline {
  padding: 0;
}
.hsec {
  margin-top: 18px;
}
.hsec h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--dim);
  font-weight: 600;
}
.empty {
  padding: 30px 0;
}
.star {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: 0;
  color: var(--dim);
  font-size: 17px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 6px;
  opacity: 0;
}
.tcard:hover .star,
.tcard:focus-within .star,
.star.on {
  opacity: 1;
}
.star.on {
  color: #f0b429;
}
.tcard:focus-visible,
.catcard:focus-visible,
.hub-side .tab:focus-visible,
.prow:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
}
.catgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.catcard {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font: inherit;
}
.catcard:hover {
  border-color: var(--accent);
}
.dropveil {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  z-index: 60;
  pointer-events: none;
  border: 3px dashed var(--accent);
}
.ticon.sm {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex: none;
}
.ticon.sm svg {
  width: 17px;
  height: 17px;
}

/* ---- side drawer ---- */
.drawer-wrap {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 40;
  display: flex;
  justify-content: flex-end;
}
.drawer {
  width: min(680px, 100%);
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.35);
  transform: translateX(30px);
  opacity: 0;
  transition:
    transform 0.16s ease-out,
    opacity 0.16s;
}
.drawer-wrap.open .drawer {
  transform: none;
  opacity: 1;
}
.drawer-wrap.wide .drawer {
  width: min(1100px, 100%);
}
.tool-head h3 {
  margin: 0 0 6px;
  font-size: 18px;
}
.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.swatch.on {
  border-color: var(--text);
}
.diag {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  white-space: pre-wrap;
  user-select: text;
  margin: 0;
  max-height: 220px;
  overflow: auto;
}

/* ---- command palette ---- */
.palette {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 80;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
}
.pcard {
  width: min(620px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.pcard input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 14px 16px;
  font-size: 16px;
  outline: none;
}
.plist {
  max-height: 54vh;
  overflow: auto;
  padding: 6px;
}
.prow {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.prow.on,
.prow:hover {
  background: var(--panel-2);
}
.prow .grow {
  flex: 1;
  min-width: 0;
}

/* before/after slider */
.cmp {
  position: relative;
  width: 100%;
  height: 300px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  cursor: ew-resize;
  user-select: none;
  touch-action: none;
  margin: 8px 0;
  background: repeating-conic-gradient(#8885 0 25%, #0000 0 50%) 0 0/16px 16px;
}
.cmp img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.cmp-top {
  position: absolute;
  inset: 0;
}
.cmp-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px #0006;
  transform: translateX(-1px);
}
.cmp-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: 0 1px 6px #0006;
}
.cmp-tag {
  position: absolute;
  top: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #000a;
  color: #fff;
  font-size: 11px;
  pointer-events: none;
}
.cmp-tag.l {
  left: 8px;
}
.cmp-tag.r {
  right: 8px;
}
.pdfthumb {
  height: 54px;
  width: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  margin-right: 8px;
  flex: none;
}

.chartbox {
  margin: 10px 0;
}
.chart {
  width: 100%;
  height: auto;
  max-width: 680px;
  display: block;
}
.cgrid {
  stroke: var(--line);
  stroke-width: 1;
}
.ctext {
  fill: var(--dim);
  font-size: 10px;
}
.clegend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--dim);
  margin-top: 4px;
}
.clegend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  vertical-align: -1px;
}
.dupthumb {
  max-height: 72px;
  max-width: 120px;
  border-radius: 4px;
  border: 1px solid var(--line);
  align-self: flex-start;
  margin-bottom: 4px;
  object-fit: cover;
}
.wave {
  width: 100%;
  height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: col-resize;
  margin: 6px 0;
  touch-action: none;
}
.btn.cite {
  padding: 1px 9px;
  font-size: 12px;
  border-radius: 12px;
}
.drawer .btn:not(.primary) {
  border-color: var(--line);
  background: var(--panel-2);
}
.drawer .btn:not(.primary):hover:not(:disabled) {
  background: var(--hover);
  border-color: var(--accent);
}
.drawer .btn.cite {
  background: transparent;
}

.rxhl {
  white-space: pre-wrap;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  min-height: 40px;
  max-height: 200px;
  overflow: auto;
  background: var(--field);
}
.rxhl mark {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  color: inherit;
  border-radius: 3px;
  outline: 1px solid var(--accent);
}
.swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.swatch {
  cursor: pointer;
  width: 84px;
  font-size: 11px;
  text-align: center;
}
.swatch div {
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.swatch span {
  display: block;
  margin-top: 2px;
  color: var(--dim);
}
.qtable {
  border-collapse: collapse;
  width: 100%;
  font-size: 12.5px;
}
.qtable th,
.qtable td {
  border: 1px solid var(--line);
  padding: 3px 8px;
  text-align: left;
}
.qtable th {
  background: var(--panel-2);
  position: sticky;
  top: 0;
}
.kanban {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}
.kcol {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  min-height: 180px;
}
.kcol.over {
  outline: 2px dashed var(--accent);
}
.khead {
  font-weight: 600;
  font-size: 12.5px;
  margin-bottom: 6px;
}
.kcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 6px;
  cursor: grab;
  font-size: 13px;
}
.kcard .trow {
  margin-top: 4px;
}
.red {
  color: #d9363e;
}

/* ---- shared tool pieces (the website adds its own look in app-theme.css) ---- */
.tdrop {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px;
  border: 2px dashed var(--line);
  border-radius: 12px;
}
.tdrop.over {
  border-color: var(--accent);
}
.tdrop .dz-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--accent);
  flex: none;
}
.tdrop .dz-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 150px;
}
.tdrop .dz-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tdrop.compact {
  padding: 8px 12px;
  border-style: solid;
  border-width: 1px;
}
.tdrop.compact .dz-text .dim {
  display: none;
}
.fbadge {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--panel);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}
.ttabs {
  flex-wrap: wrap;
}
.tstats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}
.tstats > :not(.tstat) {
  grid-column: 1 / -1;
}
.tstat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}
.tstat .tstat-l {
  font-size: 12px;
  color: var(--dim);
}
.tstat .tstat-v {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.tstat.hero {
  grid-column: 1 / -1;
  border-color: var(--accent);
}
.tstat.hero .tstat-v {
  font-size: 26px;
  font-weight: 700;
}
.tool-head .ticon.head {
  width: 36px;
  height: 36px;
  flex: none;
  margin-right: 10px;
}
.tool-head h3 {
  flex: 1;
}
.tool-body > *,
.tstats > *,
.ttabs > * {
  flex-shrink: 0;
}

/* preview of the chosen file(s) */
.tpreview {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tpreview:empty {
  display: none;
}
.tpv {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.tpv-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}
.tpv-head b {
  overflow-wrap: anywhere;
}
.tpv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  max-height: 380px;
  overflow: auto;
  padding: 4px;
}
.tpv-page {
  position: relative;
  display: block;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #fff;
  min-height: 138px;
  overflow: hidden;
  cursor: default;
  font: inherit;
}
button.tpv-page {
  cursor: pointer;
}
.tpv-page .tpv-img {
  display: block;
  width: 100%;
  height: auto;
}
.tpv-num {
  position: absolute;
  left: 6px;
  bottom: 6px;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.tpv-page.on {
  border-color: #ff7a59;
  box-shadow: 0 0 0 3px rgba(255, 122, 89, 0.28);
}
.tpv-page.on::after {
  content: '✓';
  position: absolute;
  right: 6px;
  top: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ff7a59;
  color: #fff;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  font-weight: 800;
}
.tpv-page.failed::before {
  content: 'Could not draw this page';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  font-size: 12px;
  text-align: center;
  opacity: 0.7;
}
.tpv-pic,
.tpv-media {
  max-width: 100%;
  max-height: 320px;
  border-radius: 12px;
  align-self: flex-start;
  background: #fff;
  object-fit: contain;
}
.tpv-audio {
  width: 100%;
}
.tpv-text {
  margin: 0;
  max-height: 180px;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
  font-size: 12.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.tpv-count {
  color: #d9482b;
  font-weight: 800;
}
