/* ---------- Design-Variablen ---------- */
:root {
  --bg: #f3f4f7;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --text: #1a1e27;
  --muted: #6b7482;
  --line: #e3e6ec;
  --hover: #eceef3;
  --accent: #2563eb;
  --accent-weak: #e4ecfd;
  --accent-text: #1d4ed8;
  --danger: #d6342c;
  --ink: #16181d;
  --shadow: 0 8px 28px rgba(20, 28, 48, 0.16), 0 1px 3px rgba(20, 28, 48, 0.1);
  --radius: 10px;
  --sidebar-w: 292px;
  --tb-h: 56px;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #121418;
  --panel: #1a1d23;
  --panel-2: #20242b;
  --text: #e8eaef;
  --muted: #98a1af;
  --line: #2b3039;
  --hover: #262b34;
  --accent: #5b8cff;
  --accent-weak: #22304f;
  --accent-text: #9db9ff;
  --danger: #ff6b62;
  --ink: #f0f1f4;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #121418;
    --panel: #1a1d23;
    --panel-2: #20242b;
    --text: #e8eaef;
    --muted: #98a1af;
    --line: #2b3039;
    --hover: #262b34;
    --accent: #5b8cff;
    --accent-weak: #22304f;
    --accent-text: #9db9ff;
    --danger: #ff6b62;
    --ink: #f0f1f4;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', sans-serif;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
body {
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}
svg {
  display: block;
  flex: none;
}
[hidden] {
  display: none !important;
}

#app {
  display: flex;
  height: 100%;
  height: 100dvh;
}

/* ---------- Seitenleiste ---------- */
#sidebar {
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  margin-left: calc(-1 * var(--sidebar-w));
  transition: margin-left 0.2s ease;
  padding-top: env(safe-area-inset-top);
  z-index: 30;
}
body.sidebar-open #sidebar {
  margin-left: 0;
}
.sb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 8px;
  gap: 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
}
.logo svg {
  width: 17px;
  height: 17px;
}
.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 9px;
  border-radius: 99px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.sync-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.sync-pill.ok .dot {
  background: #27ae60;
}
.sync-pill.wait .dot {
  background: #f5a623;
  animation: pulse 1s infinite;
}
.sync-pill.off .dot,
.sync-pill.err .dot {
  background: var(--danger);
}
@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

.sb-search {
  position: relative;
  margin: 4px 12px 8px;
  display: flex;
  align-items: center;
}
.sb-search svg {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.search {
  width: 100%;
  height: 36px;
  padding: 0 10px 0 33px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.search:focus {
  border-color: var(--accent);
  background: var(--panel);
}
.sb-actions {
  display: flex;
  gap: 8px;
  padding: 0 12px 10px;
}
.sb-actions .btn {
  flex: 1;
}

.tree {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
  -webkit-overflow-scrolling: touch;
}
.tree.drop-root {
  box-shadow: inset 0 -3px 0 var(--accent);
}
.row {
  --depth: 0;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 6px 0 calc(4px + var(--depth) * 16px);
  border-radius: 8px;
  cursor: pointer;
}
.row:hover {
  background: var(--hover);
}
.row.active {
  background: var(--accent-weak);
  color: var(--accent-text);
}
.row.dragging {
  opacity: 0.4;
}
.row .chev {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: transform 0.15s;
}
.row .chev svg {
  width: 14px;
  height: 14px;
}
.row.open > .chev {
  transform: rotate(90deg);
}
.row .chev.hidden {
  visibility: hidden;
}
.row .ico {
  display: grid;
  place-items: center;
  color: var(--muted);
}
.row.folder .ico {
  color: #d99a1e;
}
.row.active .ico {
  color: inherit;
}
.row .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .name small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.1;
}
.row .mini {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--muted);
  opacity: 0;
}
.row:hover .mini,
.row.active .mini,
.row .mini:focus-visible {
  opacity: 1;
}
@media (hover: none) {
  .row .mini {
    opacity: 1;
  }
}
.row .mini:hover {
  background: var(--line);
  color: var(--text);
}
.row .mini.danger:hover {
  color: var(--danger);
}
.row.drop-before::before,
.row.drop-after::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}
.row.drop-before::before {
  top: -2px;
}
.row.drop-after::after {
  bottom: -2px;
}
.row.drop-into {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--accent-weak);
}
.rename-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--panel);
  padding: 0 8px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.empty-tree {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}
.trash-head {
  display: flex;
  justify-content: space-between;
  padding: 4px 4px 8px;
}
.sb-foot {
  display: flex;
  gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.foot-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.foot-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.foot-btn svg {
  width: 17px;
  height: 17px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  white-space: nowrap;
}
.btn:hover {
  background: var(--hover);
}
.btn svg {
  width: 17px;
  height: 17px;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover {
  filter: brightness(1.08);
}
.btn.primary.danger {
  background: var(--danger);
  border-color: var(--danger);
}
.btn.danger-text {
  color: var(--danger);
}

/* ---------- Hauptbereich ---------- */
#main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
#toolbar {
  height: calc(var(--tb-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 8px;
  padding-right: 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.title-block {
  display: flex;
  flex-direction: column;
  min-width: 70px;
  max-width: 220px;
  flex: 0 1 150px;
  padding: 0 6px;
}
.crumb {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 14px;
  line-height: 14px;
}
.note-title {
  border: 0;
  background: transparent;
  font-weight: 600;
  font-size: 15px;
  padding: 0;
  height: 22px;
  min-width: 0;
  outline: none;
  border-radius: 4px;
  -webkit-user-select: text;
  user-select: text;
}
.note-title:focus {
  box-shadow: 0 0 0 2px var(--accent);
}
.tb-scroll {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 4px;
}
/* mittig, solange Platz ist – sonst von links scrollbar (statt links abgeschnitten) */
.tb-scroll > :first-child {
  margin-left: auto;
}
.tb-scroll > :last-child {
  margin-right: auto;
}
.tb-scroll::-webkit-scrollbar {
  display: none;
}
.group {
  display: flex;
  gap: 1px;
  padding: 2px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  flex: none;
}
.tb {
  position: relative;
  width: 38px;
  height: 42px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--text);
  flex: none;
}
.tb:hover {
  background: var(--hover);
}
.tb.active {
  background: var(--accent-weak);
  color: var(--accent-text);
}
.tb:disabled {
  opacity: 0.35;
  cursor: default;
  background: none;
}
.tb svg {
  width: 21px;
  height: 21px;
}
.pens {
  display: flex;
  gap: 2px;
}
.tb.pen svg {
  color: var(--c, var(--ink));
  transform: translateY(-2px);
}
.tb.pen.active svg {
  filter: drop-shadow(0 0 0.5px var(--text));
}
.pen-bar {
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: 5px;
  height: var(--bar, 2px);
  border-radius: 4px;
  background: var(--c, var(--ink));
}
.tb.pen[data-type='hl'] .pen-bar {
  opacity: 0.75;
}
.tb.shapes {
  position: relative;
}
.lock-dot {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
}
.lock-dot svg {
  width: 10px;
  height: 10px;
  stroke-width: 2.6;
}
body.no-note .tb-scroll,
body.no-note .hud {
  opacity: 0.35;
  pointer-events: none;
}

/* ---------- Zeichenfläche ---------- */
#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #fff;
  overflow: hidden;
}
/* Fenster (eine oder zwei Notizen) */
.panes {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: row;
}
.panes.col {
  flex-direction: column;
}
.pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}
.pane-host {
  position: absolute;
  inset: 0;
}
.panes.split .pane-host {
  top: 34px;
}
.pane-bar {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 4px 0 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 6;
}
.panes.split .pane-bar {
  display: flex;
}
.pane.active .pane-bar::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--accent);
}
.pane-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  font-weight: 600;
  color: var(--muted);
}
.pane.active .pane-title {
  color: var(--text);
}
.pane-title:hover {
  background: var(--hover);
}
.pane-title svg {
  width: 16px;
  height: 16px;
}
.pane-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pane-close {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--muted);
  flex: none;
}
.pane-close:hover {
  background: var(--hover);
  color: var(--text);
}
.pane-close svg {
  width: 15px;
  height: 15px;
}
.pane-divider {
  position: relative;
  flex: none;
  width: 8px;
  background: var(--line);
  cursor: col-resize;
  z-index: 8;
  touch-action: none;
}
.panes.col .pane-divider {
  width: auto;
  height: 8px;
  cursor: row-resize;
}
.pane-divider::before {
  content: '';
  position: absolute;
  inset: 0 -8px;
}
.panes.col .pane-divider::before {
  inset: -8px 0;
}
.pane-divider:hover,
.pane-divider.drag {
  background: var(--accent);
}
.pane-swap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--muted);
  z-index: 2;
}
.pane-swap svg {
  width: 14px;
  height: 14px;
}
.pane-swap:hover {
  color: var(--text);
  background: var(--hover);
}
.pane-empty {
  display: none;
  position: absolute;
  inset: 0;
  place-items: center;
  background: var(--bg);
  padding: 24px;
  overflow-y: auto;
  z-index: 5;
}
.pane.empty .pane-empty {
  display: grid;
}
.pane.empty .pane-host,
.pane.empty .hud {
  visibility: hidden;
}
.empty-card.wide {
  width: min(460px, 100%);
  max-width: none;
}
.empty-card h2 {
  color: var(--text);
  margin: 0 0 12px;
  font-size: 18px;
}
.pick {
  text-align: left;
}
.pick-search {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  outline: none;
  margin-bottom: 8px;
  -webkit-user-select: text;
  user-select: text;
}
.pick-search:focus {
  border-color: var(--accent);
}
.pick-list {
  max-height: 42vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 4px;
}
.pick-row small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.1;
}
.popup.pick-popup {
  width: min(360px, calc(100vw - 16px));
  padding: 10px;
}
.cv-base,
.cv-live {
  position: absolute;
  left: 0;
  top: 0;
}
.cv-live {
  touch-action: none;
}
body.space-pan .cv-live {
  cursor: grab !important;
}
.empty-card {
  text-align: center;
  max-width: 420px;
  color: var(--muted);
}
.empty-card h1 {
  color: var(--text);
  font-size: 22px;
  margin: 14px 0 6px;
}
.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  margin: 0 auto;
  background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14.5 5.5l4 4M4 20l1-4.5L16.5 4a1.9 1.9 0 012.7 0l.8.8a1.9 1.9 0 010 2.7L8.5 19 4 20z'/%3E%3C/svg%3E")
    center / 34px no-repeat;
}
input.cv-title-input {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 1.5px dashed var(--accent);
  outline-offset: 3px;
  background: transparent;
  caret-color: var(--accent);
  -webkit-user-select: text;
  user-select: text;
  text-overflow: ellipsis;
}
textarea.cv-text {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 1.5px dashed var(--accent);
  outline-offset: 3px;
  background: transparent;
  resize: none;
  overflow: hidden;
  white-space: pre;
  caret-color: var(--accent);
  -webkit-user-select: text;
  user-select: text;
  z-index: 5;
}

.hud {
  position: absolute;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 10;
}
.hud-btn {
  min-width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 18px;
}
.hud-btn:hover {
  background: var(--hover);
}
.hud-btn.pct {
  font-size: 13px;
  min-width: 58px;
  font-variant-numeric: tabular-nums;
}
.hud-btn svg {
  width: 19px;
  height: 19px;
}

.selbar {
  position: absolute;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 10;
}
.sel-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.sel-btn:hover {
  background: var(--hover);
}
.sel-btn.danger {
  color: var(--danger);
}
.sel-color {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1.5px var(--muted);
}

/* ---------- Popover & Menüs ---------- */
.popup {
  position: fixed;
  z-index: 100;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: pop 0.12s ease-out;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}
.pop-body {
  width: 270px;
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pop-body.wide {
  width: 320px;
}
.pop-body h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1.5px var(--line);
  position: relative;
  cursor: pointer;
}
.swatch[data-c='@ink'] {
  background: linear-gradient(135deg, #16181d 50%, #f2f2f2 50%);
}
.swatch.on {
  box-shadow: 0 0 0 2.5px var(--accent);
}
.swatch.custom {
  background: conic-gradient(#f33, #fc3, #3c6, #3cf, #63f, #f3c, #f33);
  overflow: hidden;
}
.swatch.custom input {
  position: absolute;
  inset: -6px;
  opacity: 0;
  width: 44px;
  height: 44px;
  cursor: pointer;
}
.slider {
  display: grid;
  grid-template-columns: 52px 1fr 54px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.slider .val {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
  height: 28px;
}
.preview {
  height: 40px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  display: grid;
  align-items: center;
  padding: 0 16px;
}
.stroke-prev {
  display: block;
  border-radius: 99px;
  min-height: 1px;
}
.stroke-prev.hl {
  opacity: 0.6;
}
.seg {
  display: flex;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}
.seg button {
  flex: 1;
  height: 32px;
  border-radius: 7px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.seg button.on {
  background: var(--panel);
  box-shadow: 0 0 0 1.5px var(--accent);
  color: var(--accent-text);
}
.paper-chip {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid var(--muted);
}
.radio-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.radio-list label,
label.check {
  display: flex;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  align-items: flex-start;
  cursor: pointer;
}
.radio-list label:hover,
label.check:hover {
  background: var(--hover);
}
.radio-list label span {
  display: flex;
  flex-direction: column;
}
.radio-list small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}
.radio-list input,
label.check input {
  margin-top: 3px;
  accent-color: var(--accent);
}
.menu {
  min-width: 220px;
  padding: 6px;
}
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  text-align: left;
}
.menu-item:hover {
  background: var(--hover);
}
.menu-item.danger {
  color: var(--danger);
}
.menu-item svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}
.menu-item.danger svg {
  color: inherit;
}
.ico-gap {
  width: 18px;
}
.sep {
  height: 1px;
  background: var(--line);
  margin: 5px 4px;
}

/* ---------- Dialoge ---------- */
dialog.modal {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  max-width: min(440px, calc(100vw - 24px));
  width: 100%;
}
dialog.modal::backdrop {
  background: rgba(10, 14, 24, 0.5);
  backdrop-filter: blur(2px);
}
.dlg {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  -webkit-user-select: text;
  user-select: text;
}
.dlg h2 {
  margin: 0 0 4px;
  font-size: 18px;
}
.dlg p {
  margin: 0;
  color: var(--muted);
}
.dlg label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-top: 4px;
}
.dlg input,
.dlg select {
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 0 12px;
  outline: none;
}
.dlg input:focus,
.dlg select:focus {
  border-color: var(--accent);
}
.dlg .kv {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  padding: 8px 12px;
  background: var(--panel-2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  word-break: break-all;
}
.dlg .hint {
  font-size: 13px;
}
.dlg .hint.err,
.dlg .hint b.err {
  color: var(--danger);
}
.dlg .hint.warn {
  color: var(--text);
  background: var(--accent-weak);
  border-radius: var(--radius);
  padding: 8px 12px;
}
.dlg .hint.warn:empty {
  display: none;
}
.dlg progress {
  width: 100%;
  height: 10px;
  accent-color: var(--accent);
}
.dlg-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}
.picker {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
}
.pick-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding-right: 10px;
  border-radius: 8px;
  text-align: left;
}
.pick-row:hover {
  background: var(--hover);
}
.pick-row svg {
  color: #d99a1e;
  width: 18px;
  height: 18px;
}

#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  transition: opacity 0.3s;
}
.toast.out {
  opacity: 0;
}
/* Hinweis "Neue Version bereit" (auto-update.js): klein und unten links, damit er beim Schreiben nicht stört */
.update-pill {
  position: fixed;
  left: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 190;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 14px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 13px;
}
.update-pill button {
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

/* ---------- Schmale Fenster (Tablet hochkant, Handy) ---------- */
#backdrop {
  display: none;
}
@media (max-width: 860px) {
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    margin-left: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
    width: min(var(--sidebar-w), 86vw);
  }
  body.sidebar-open #sidebar {
    transform: none;
  }
  body.sidebar-open #backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 24, 0.4);
    z-index: 25;
  }
  .title-block {
    display: none;
  }
  .tb-scroll {
    gap: 6px;
  }
  .tb {
    width: 38px;
    height: 40px;
  }
  .pen-bar {
    left: 9px;
    right: 9px;
  }
}
@media (max-width: 520px) {
  .tb {
    width: 36px;
  }
  #toolbar {
    gap: 2px;
    padding-left: 4px;
    padding-right: 4px;
  }
}

/* ---------- Formen-Auswahl, Hinweise ---------- */
.shape-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.shape-btn {
  width: 44px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
}
.shape-btn:hover {
  background: var(--hover);
}
.shape-btn.on {
  background: var(--accent-weak);
  color: var(--accent-text);
  border-color: var(--accent);
}
.pop-body .hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}
.pop-body .btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---------- Wiedergabe-Leiste ---------- */
.replay-bar {
  position: absolute;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 12;
}
.rp-btn {
  min-width: 44px;
  height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
}
.rp-btn:hover {
  background: var(--hover);
}
body.replaying .tb-scroll,
body.replaying .selbar {
  opacity: 0.4;
  pointer-events: none;
}

/* ---------- Ganzseitenansicht ---------- */
#focus-exit {
  display: none;
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  z-index: 15;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  place-items: center;
  opacity: 0.75;
}
#focus-exit:hover {
  opacity: 1;
}
body.focus #focus-exit {
  display: grid;
}
body.focus #sidebar,
body.focus #toolbar,
body.focus #backdrop {
  display: none !important;
}

/* Auf mittleren Breiten Platz für die Werkzeuge schaffen: der Titel steht auch in der Seitenleiste */
@media (max-width: 1650px) {
  .title-block {
    display: none;
  }
}

/* ---------- Claude: Anzeige & "schau hier" ---------- */
.claude-chip {
  position: absolute;
  left: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px 0 10px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: #7c3aed;
  font-size: 13px;
  font-weight: 600;
}
:root[data-theme='dark'] .claude-chip {
  color: #b79bff;
}
.claude-chip .cl-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.claude-chip.on .cl-dot {
  background: #27ae60;
}
.claude-chip:hover {
  background: var(--hover);
}
.claude-chip .cl-label {
  color: var(--text);
  font-weight: 500;
}
/* "Übernehmen · ×" an Claudes Schrift */
.cl-pills {
  position: absolute;
  inset: 0;
  z-index: 8;
  overflow: hidden;
  pointer-events: none;
}
.cl-pill {
  position: absolute;
  display: flex;
  align-items: stretch;
  height: 28px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
  border: 1.5px solid #7c3aed;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.25);
  color: #7c3aed;
  font-size: 12.5px;
  font-weight: 600;
  pointer-events: auto;
}
.cl-pill[hidden] {
  display: none;
}
:root[data-theme='dark'] .cl-pill {
  color: #b79bff;
  border-color: #b79bff;
}
.cl-pill button {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px 0 9px;
  color: inherit;
  font: inherit;
  white-space: nowrap;
}
.cl-pill button:hover {
  background: rgba(124, 58, 237, 0.14);
}
.cl-pill svg {
  width: 14px;
  height: 14px;
}
.cl-pill .cl-pill-x {
  padding: 0 8px;
  border-left: 1px solid rgba(124, 58, 237, 0.3);
  color: var(--muted);
}
.cl-pill .cl-pill-x:hover {
  color: var(--danger);
}
@media (pointer: coarse) {
  .cl-pill {
    height: 34px;
    border-radius: 17px;
  }
}

.claude-ping {
  position: absolute;
  z-index: 9;
  pointer-events: none;
  border: 3px solid #7c3aed;
  border-radius: 14px;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.2);
  animation: claude-ping 1.1s ease-out 4;
}
@keyframes claude-ping {
  0% {
    transform: scale(1.18);
    opacity: 0;
  }
  35% {
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
}

/* ---------- Verbindung und Geräte ---------- */
.conn-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
}
.conn-status .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--muted);
}
.conn-status .dot.ok {
  background: #27ae60;
}
.conn-status .dot.wait {
  background: #f5a623;
  animation: pulse 1s infinite;
}
.conn-status .dot.off,
.conn-status .dot.err {
  background: var(--danger);
}
.conn-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  color: var(--muted);
}
.conn-meta code {
  font-family: ui-monospace, Consolas, monospace;
  color: var(--text);
  word-break: break-all;
}
.conn-advice {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 10px 12px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.conn-advice.bad {
  border-color: var(--danger);
}
.conn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dlg h3 {
  margin: 8px 0 0;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.dev-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 34vh;
  overflow-y: auto;
}
.dev {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}
.dev-ico {
  font-size: 22px;
  width: 30px;
  text-align: center;
}
.dev small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Server-Liste ---------- */
.srv-list {
  max-height: 40vh;
}
.srv {
  align-items: flex-start;
}
.srv-dot {
  flex: none;
  width: 11px;
  height: 11px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--muted);
}
.srv-dot.ok,
.srv-dot.on {
  background: #27ae60;
}
.srv-dot.wait,
.srv-dot.warn {
  background: #f5a623;
}
.srv-dot.wait {
  animation: pulse 1s infinite;
}
.srv-dot.bad {
  background: var(--danger);
}
.srv-main {
  flex: 1;
  min-width: 0;
}
.srv-main b {
  cursor: pointer;
}
.srv-main small {
  word-break: break-word;
}
.dev small.srv-bad {
  color: var(--danger);
}
.dev small.srv-warn {
  color: #b7791f;
}
.srv-btns {
  display: flex;
  flex: none;
  gap: 4px;
}
.srv-btns .btn {
  min-width: 32px;
  padding: 4px 8px;
}
.srv-add {
  display: flex;
  gap: 8px;
}
.srv-add input {
  flex: 1;
  min-width: 0;
}

/* ---------- OneNote-Import ---------- */
dialog.modal.imp-modal {
  max-width: min(580px, calc(100vw - 24px));
}
.imp-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 72vh;
  overflow-y: auto;
}
.imp-steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.imp-steps a {
  color: var(--accent-text);
}
.imp-steps code {
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 5px;
  word-break: break-all;
}
.imp-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 30vh;
  overflow-y: auto;
}
.dlg label.imp-row,
.dlg label.imp-check,
.dlg label.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}
.dlg label.imp-row {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}
.dlg .imp-row input,
.dlg .imp-check input,
.dlg label.check input {
  width: 18px;
  height: 18px;
  padding: 0;
  flex: none;
  accent-color: var(--accent);
}
.imp-row small {
  color: var(--muted);
}
.imp-status {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.imp-status small {
  color: var(--muted);
  word-break: break-word;
}
.imp-status small.err {
  color: var(--danger);
}
.imp-counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 8px;
}
.imp-counts > div {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}
.imp-counts b {
  font-size: 18px;
}
.imp-counts small {
  color: var(--muted);
  font-size: 12px;
}
.imp-details details {
  font-size: 13px;
  margin: 4px 0;
}
.imp-details summary {
  cursor: pointer;
  font-weight: 600;
}
.imp-details ul {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--muted);
  max-height: 22vh;
  overflow-y: auto;
  word-break: break-word;
}

/* ---------- Export ---------- */
dialog.modal.exp-modal {
  max-width: min(480px, calc(100vw - 24px));
}
.dlg.exp .exp-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 64vh;
  overflow-y: auto;
}
.dlg.exp .exp-body h3 {
  margin: 6px 0 0;
}
.dlg.exp .seg {
  flex-wrap: wrap;
}
.dlg.exp .hint.err {
  color: var(--danger);
}
.margin-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.margin-block[hidden] {
  display: none;
}

/* ---------- Status-Karte (Einstellungen / Verbindung) ---------- */
.status-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.status-card[data-level='bad'] {
  border-color: var(--danger);
}
.st-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.st-head .btn {
  margin-left: auto;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}
.st-title {
  font-size: 14px;
}
.st-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}
.st-dot.ok {
  background: #27ae60;
}
.st-dot.warn {
  background: #f5a623;
}
.st-dot.bad {
  background: var(--danger);
}
.st-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.st-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
}
.st-row .st-body b {
  color: var(--text);
  font-weight: 600;
}
.st-row .btn {
  flex: none;
  margin-left: auto;
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
}
.st-ico {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--muted);
}
.st-row.ok .st-ico {
  background: #27ae60;
}
.st-row.warn .st-ico {
  background: #f5a623;
}
.st-row.bad .st-ico {
  background: var(--danger);
}
.st-row.bad {
  color: var(--text);
}
