/* CTH Diagrams: the editor, library and shadcn v4 neutral recipes (started as
   the Obsidian plugin's CSS; the app shell is web/web.css). Tokens live on the
   three roots the app draws into: .cthd (the app), .cthd-layer (popups on
   document.body) and .cthd-modal (dialogs). Dark follows body.theme-dark.
   NOTHING DRAWN ON THE ICE follows the theme: the rink, players, lines and
   on-ice text fields are content and stay exactly as they export. */

.cthd, .cthd-layer, .cthd-modal {
  --dg-bg: oklch(1 0 0);
  --dg-fg: oklch(0.145 0 0);
  --dg-card: oklch(1 0 0);
  --dg-popover: oklch(1 0 0);
  --dg-muted: oklch(0.97 0 0);
  --dg-muted-fg: oklch(0.556 0 0);
  --dg-border: oklch(0.922 0 0);
  --dg-input: oklch(0.922 0 0);
  --dg-primary: oklch(0.205 0 0);
  --dg-primary-fg: oklch(0.985 0 0);
  --dg-secondary: oklch(0.97 0 0);
  --dg-secondary-fg: oklch(0.205 0 0);
  --dg-accent: oklch(0.97 0 0);
  --dg-accent-fg: oklch(0.205 0 0);
  --dg-destructive: oklch(0.577 0.245 27.325);
  --dg-ring: oklch(0.708 0 0);
  --dg-input-bg: transparent;
  --dg-radius-sm: 6px;
  --dg-radius: 8px;
  --dg-radius-lg: 10px;
  --dg-radius-xl: 14px;
  --dg-shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --dg-shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --dg-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --dg-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --dg-dur: 150ms;
  /* canvas chrome drawn OVER content (selection, grips, the rink mark): the
     Diagrams cyan, never the theme colour, so it shows on any player colour */
  --dg-marquee: #75d8ff;
  --dg-marquee-soft: rgba(117, 216, 255, 0.2);
  --dg-font: var(--font-interface);
  color: var(--dg-fg);
  font-family: var(--dg-font);
}
body.theme-dark .cthd, body.theme-dark .cthd-layer, body.theme-dark .cthd-modal {
  --dg-bg: oklch(0.145 0 0);
  --dg-fg: oklch(0.985 0 0);
  --dg-card: oklch(0.205 0 0);
  --dg-popover: oklch(0.205 0 0);
  --dg-muted: oklch(0.269 0 0);
  --dg-muted-fg: oklch(0.708 0 0);
  --dg-border: oklch(1 0 0 / 10%);
  --dg-input: oklch(1 0 0 / 15%);
  --dg-primary: oklch(0.922 0 0);
  --dg-primary-fg: oklch(0.205 0 0);
  --dg-secondary: oklch(0.269 0 0);
  --dg-secondary-fg: oklch(0.985 0 0);
  --dg-accent: oklch(0.269 0 0);
  --dg-accent-fg: oklch(0.985 0 0);
  --dg-destructive: oklch(0.704 0.191 22.216);
  --dg-ring: oklch(0.556 0 0);
  --dg-input-bg: oklch(1 0 0 / 4.5%);
  --dg-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
}
.cthd [hidden], .cthd-layer [hidden], .cthd-modal [hidden] { display: none !important; }
.cthd *, .cthd-layer *, .cthd-modal * { box-sizing: border-box; }

/* the views own their whole content area */
.workspace-leaf-content[data-type="cth-diagram"] > .view-content,
.workspace-leaf-content[data-type="cth-diagrams-library"] > .view-content { padding: 0; overflow: hidden; position: relative; }

/* ---- icons ------------------------------------------------------------------ */
.cthd-ic { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.cthd-ic svg { width: 16px; height: 16px; stroke-width: 2; }

/* ---- Button (shadcn v4) -------------------------------------------------------
   Every rule is (0,2,0) or more. Hover rules never change size. */
.cthd .cthd-btn, .cthd-layer .cthd-btn, .cthd-modal .cthd-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; margin: 0;
  border: 1px solid transparent; border-radius: var(--dg-radius);
  font: 500 14px/1 var(--dg-font); white-space: nowrap; cursor: pointer;
  background: transparent; color: var(--dg-fg); box-shadow: none;
  transition: background-color var(--dg-dur), color var(--dg-dur), border-color var(--dg-dur), box-shadow var(--dg-dur);
  -webkit-app-region: no-drag;
}
.cthd .cthd-btn .cthd-ic svg, .cthd-layer .cthd-btn .cthd-ic svg, .cthd-modal .cthd-btn .cthd-ic svg { width: 16px; height: 16px; }
.cthd .cthd-btn.is-sm, .cthd-modal .cthd-btn.is-sm { height: 32px; padding: 0 12px; gap: 6px; }
.cthd .cthd-btn.is-icon, .cthd-modal .cthd-btn.is-icon { width: 36px; height: 36px; padding: 0; }
.cthd .cthd-btn.is-icon-sm, .cthd-modal .cthd-btn.is-icon-sm { width: 32px; height: 32px; padding: 0; }
.cthd .cthd-btn.is-block { width: 100%; }
.cthd .cthd-btn.is-default, .cthd-modal .cthd-btn.is-default { background: var(--dg-primary); color: var(--dg-primary-fg); box-shadow: var(--dg-shadow-xs); }
.cthd .cthd-btn.is-default:hover, .cthd-modal .cthd-btn.is-default:hover { background: color-mix(in oklab, var(--dg-primary) 90%, transparent); }
.cthd .cthd-btn.is-outline, .cthd-modal .cthd-btn.is-outline { background: var(--dg-bg); border-color: var(--dg-border); box-shadow: var(--dg-shadow-xs); }
.cthd .cthd-btn.is-outline:hover, .cthd-modal .cthd-btn.is-outline:hover { background: var(--dg-accent); color: var(--dg-accent-fg); }
body.theme-dark .cthd .cthd-btn.is-outline, body.theme-dark .cthd-modal .cthd-btn.is-outline { background: var(--dg-input-bg); border-color: var(--dg-input); }
body.theme-dark .cthd .cthd-btn.is-outline:hover, body.theme-dark .cthd-modal .cthd-btn.is-outline:hover { background: oklch(1 0 0 / 8%); }
.cthd .cthd-btn.is-secondary, .cthd-modal .cthd-btn.is-secondary { background: var(--dg-secondary); color: var(--dg-secondary-fg); box-shadow: var(--dg-shadow-xs); }
.cthd .cthd-btn.is-secondary:hover, .cthd-modal .cthd-btn.is-secondary:hover { background: color-mix(in oklab, var(--dg-secondary) 80%, transparent); }
.cthd .cthd-btn.is-ghost:hover, .cthd-modal .cthd-btn.is-ghost:hover { background: var(--dg-accent); color: var(--dg-accent-fg); }
.cthd .cthd-btn.is-destructive, .cthd-modal .cthd-btn.is-destructive { background: var(--dg-destructive); color: #fff; box-shadow: var(--dg-shadow-xs); }
.cthd .cthd-btn.is-destructive:hover, .cthd-modal .cthd-btn.is-destructive:hover { background: color-mix(in oklab, var(--dg-destructive) 90%, transparent); }
.cthd .cthd-btn.is-danger { color: var(--dg-destructive); }
.cthd .cthd-btn.is-danger:hover { background: color-mix(in oklab, var(--dg-destructive) 10%, transparent); color: var(--dg-destructive); border-color: color-mix(in oklab, var(--dg-destructive) 30%, transparent); }
.cthd .cthd-btn:focus-visible, .cthd-modal .cthd-btn:focus-visible { outline: none; border-color: var(--dg-ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--dg-ring) 50%, transparent); }
.cthd .cthd-btn:disabled, .cthd-modal .cthd-btn:disabled { opacity: 0.5; pointer-events: none; }

/* ---- Badge ------------------------------------------------------------------------ */
.cthd .cthd-badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px;
  border: 1px solid transparent; border-radius: var(--dg-radius);
  font: 500 12px/1 var(--dg-font); white-space: nowrap; background: transparent; color: var(--dg-fg);
  font-variant-numeric: tabular-nums; max-width: 100%;
}
.cthd .cthd-badge > span:not(.cthd-ic) { overflow: hidden; text-overflow: ellipsis; }
.cthd .cthd-badge .cthd-ic svg { width: 12px; height: 12px; }
.cthd .cthd-badge.is-secondary { background: var(--dg-secondary); color: var(--dg-secondary-fg); }
.cthd .cthd-badge.is-outline { border-color: var(--dg-border); }
.cthd button.cthd-badge.is-clickable { cursor: pointer; box-shadow: none; }
.cthd button.cthd-badge.is-clickable:hover { background: var(--dg-accent); }
.cthd .cthd-status.is-dirty { background: color-mix(in oklab, oklch(0.75 0.15 80) 25%, transparent); }
.cthd .cthd-status.is-saving { color: var(--dg-muted-fg); background: color-mix(in oklab, oklch(0.62 0.19 260) 14%, transparent); }

/* ---- Input -------------------------------------------------------------------------- */
.cthd .cthd-input, .cthd-modal .cthd-input {
  width: 100%; height: 36px; padding: 4px 12px; margin: 0;
  border: 1px solid var(--dg-input); border-radius: var(--dg-radius);
  background: var(--dg-input-bg); color: var(--dg-fg); box-shadow: var(--dg-shadow-xs);
  font: 400 14px/1.4 var(--dg-font); outline: none;
  transition: border-color var(--dg-dur), box-shadow var(--dg-dur);
}
.cthd .cthd-input::placeholder, .cthd-modal .cthd-input::placeholder { color: var(--dg-muted-fg); }
.cthd .cthd-input:focus, .cthd-modal .cthd-input:focus { border-color: var(--dg-ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--dg-ring) 50%, transparent); }
.cthd-modal .cthd-label, .cthd .cthd-label { display: block; font: 500 12px/1.3 var(--dg-font); color: var(--dg-muted-fg); }
.cthd-modal .cthd-label { margin-bottom: 8px; font-size: 14px; color: var(--dg-fg); }

.cthd-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cthd-row.is-wrap { flex-wrap: wrap; }
.cthd-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cthd-grow { flex: 1; }
.cthd .cthd-hint { margin: 0; font: 400 12px/1.45 var(--dg-font); color: var(--dg-muted-fg); }
/* ================================================================================
   THE LIBRARY
   ================================================================================ */
.cthd-lib { display: flex; flex-direction: column; height: 100%; background: var(--dg-bg); --card-min: 240px; }
.cthd-lib.is-size-sm { --card-min: 180px; }
.cthd-lib.is-size-lg { --card-min: 320px; }
.cthd-lib-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--dg-border); flex-wrap: wrap; }
.cthd-lib-left, .cthd-lib-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cthd-lib-right { flex-wrap: wrap; justify-content: flex-end; }
.cthd-crumbs { display: flex; align-items: center; gap: 4px; min-width: 0; flex-wrap: wrap; }
.cthd .cthd-crumb { height: auto; padding: 2px 4px; margin: 0; border: 0; border-radius: var(--dg-radius-sm); background: none; box-shadow: none; font: 400 14px/1.4 var(--dg-font); color: var(--dg-muted-fg); cursor: pointer; }
.cthd .cthd-crumb:hover { color: var(--dg-fg); background: none; }
.cthd .cthd-crumb.is-current { color: var(--dg-fg); font-weight: 600; cursor: default; }
.cthd-crumb-sep svg { width: 14px; height: 14px; color: var(--dg-muted-fg); }
.cthd-search { position: relative; display: flex; align-items: center; }
.cthd-search > .cthd-ic { position: absolute; left: 10px; color: var(--dg-muted-fg); pointer-events: none; }
.cthd-search > .cthd-ic svg { width: 15px; height: 15px; }
.cthd .cthd-search .cthd-input { height: 32px; width: 220px; padding-left: 32px; }
.cthd-lib-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; overscroll-behavior: contain; }
.cthd-lib-section { margin: 4px 0 10px; font: 500 12px/1 var(--dg-font); color: var(--dg-muted-fg); }
.cthd-lib-section:not(:first-child) { margin-top: 24px; }
.cthd-folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.cthd .cthd-folder {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; margin: 0;
  border: 1px solid var(--dg-border); border-radius: var(--dg-radius-lg); background: var(--dg-card); color: var(--dg-fg);
  box-shadow: var(--dg-shadow-xs); font: 500 14px/1 var(--dg-font); cursor: pointer; text-align: left;
  transition: background var(--dg-dur);
}
.cthd .cthd-folder:hover { background: var(--dg-accent); }
.cthd .cthd-folder .cthd-ic { color: var(--dg-muted-fg); }
.cthd-folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cthd-folder-count { color: var(--dg-muted-fg); font-size: 12px; font-variant-numeric: tabular-nums; }
.cthd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr)); gap: 16px; }
.cthd-card {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden; cursor: pointer; outline: none;
  background: var(--dg-card); border: 1px solid var(--dg-border); border-radius: var(--dg-radius-xl); box-shadow: var(--dg-shadow-xs);
  transition: box-shadow var(--dg-dur), border-color var(--dg-dur);
}
.cthd-card:hover { box-shadow: var(--dg-shadow-md); }
.cthd-card:focus-visible { border-color: var(--dg-ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--dg-ring) 50%, transparent); }
.cthd-card-pic { position: relative; aspect-ratio: 16 / 9; background: #ffffff; border-bottom: 1px solid var(--dg-border); overflow: hidden; }
/* absolutely placed, so a tall sequence can never stretch the card */
.cthd-thumb { position: absolute; left: 8px; top: 8px; width: calc(100% - 16px); height: calc(100% - 16px); object-fit: contain; display: block; }
.cthd-corner { position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; border-radius: var(--dg-radius-sm); background: oklch(0.145 0 0 / 72%); color: #fff; font: 500 11px/1.4 var(--dg-font); font-variant-numeric: tabular-nums; }
.cthd .cthd-card-more { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity var(--dg-dur); }
.cthd-card:hover .cthd-card-more, .cthd-card:focus-within .cthd-card-more { opacity: 1; }
.cthd-card-meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cthd-card-name { font: 500 14px/1.3 var(--dg-font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cthd-card-sub { font: 400 12px/1.3 var(--dg-font); color: var(--dg-muted-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* shadcn Empty */
.cthd-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 48px 24px; margin: 24px auto; max-width: 520px; border: 1px dashed var(--dg-border); border-radius: var(--dg-radius-xl); }
.cthd-view > .cthd-empty { height: auto; }
.cthd-empty-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--dg-radius-lg); background: var(--dg-muted); color: var(--dg-fg); }
.cthd-empty-icon svg { width: 22px; height: 22px; }
.cthd-empty-title { font: 500 17px/1.3 var(--dg-font); }
.cthd-empty-desc { font: 400 14px/1.5 var(--dg-font); color: var(--dg-muted-fg); max-width: 380px; margin-bottom: 6px; }

/* the drop veil */
.cthd-drop { position: absolute; inset: 0; z-index: 10; display: none; place-items: center; background: color-mix(in oklab, var(--background-primary) 82%, transparent); border: 2px dashed var(--text-muted); border-radius: 12px; pointer-events: none; }
.cthd-drop.is-on { display: grid; }
.cthd-drop-card { display: flex; flex-direction: column; align-items: center; gap: 10px; font: 500 15px/1.3 var(--font-interface); color: var(--text-normal); }
.cthd-drop-card svg { width: 28px; height: 28px; }

/* ================================================================================
   THE LAYER: popups the editor raises (player letters, line options, right-click
   menus), the animator and the Edit pill on embeds. Fixed children only.
   ================================================================================ */
.cthd-layer { position: fixed; top: 0; left: 0; width: 0; height: 0; z-index: var(--layer-modal, 50); }

/* right-click menus: shadcn DropdownMenu */
.cthd-layer .ctxmenu {
  position: fixed; z-index: 2; min-width: 200px; padding: 4px;
  background: var(--dg-popover); color: var(--dg-fg);
  border: 1px solid var(--dg-border); border-radius: var(--dg-radius); box-shadow: var(--dg-shadow-md);
}
.cthd-layer .ctx-item {
  display: flex; align-items: center; gap: 8px; width: 100%; height: auto; padding: 6px 8px; margin: 0;
  border: 0; border-radius: var(--dg-radius-sm); background: none; box-shadow: none;
  font: 400 14px/1.3 var(--dg-font); color: var(--dg-fg); text-align: left; cursor: pointer;
}
.cthd-layer .ctx-item:hover { background: var(--dg-accent); color: var(--dg-accent-fg); }
.cthd-layer .ctx-label { flex: 1; }
.cthd-layer .ctx-hint { color: var(--dg-muted-fg); font-size: 12px; letter-spacing: 0.1em; }
.cthd-layer .ctx-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); border: 1px solid rgba(0, 0, 0, 0.22); flex: none; }
.cthd-layer .ctx-sep { height: 1px; margin: 4px -4px; background: var(--dg-border); }

/* the player letters and the line options: a shadcn Popover row */
/* ================================================================================
   DIALOGS (shadcn Dialog / AlertDialog on Obsidian's Modal)
   ================================================================================ */
.modal.cthd-modal {
  width: min(512px, calc(100vw - 32px)); padding: 24px; gap: 0;
  background: var(--dg-bg); border: 1px solid var(--dg-border); border-radius: var(--dg-radius-lg); box-shadow: var(--dg-shadow-lg);
}
.modal.cthd-modal.is-wide { width: min(720px, calc(100vw - 32px)); }
.cthd-modal .modal-title { font: 600 18px/1.3 var(--dg-font); margin-bottom: 8px; padding: 0; }
.cthd-modal .modal-content { padding: 0; }
.cthd-modal .cthd-modal-desc { margin: 0 0 16px; font: 400 14px/1.5 var(--dg-font); color: var(--dg-muted-fg); }
.cthd-modal .cthd-modal-footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.cthd-modal .cthd-keys { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; align-items: center; font: 400 14px/1.4 var(--dg-font); }
.cthd-modal .cthd-kbd-wrap { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.cthd-modal .cthd-kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 4px; background: var(--dg-muted); color: var(--dg-muted-fg); font: 500 12px/1 var(--dg-font); border: 0; box-shadow: none; }
.cthd-modal .cthd-kbd-sep { color: var(--dg-muted-fg); font-size: 12px; }
.cthd-modal .cthd-keys-v { color: var(--dg-muted-fg); }
.cthd-modal .cthd-rinklist { display: flex; flex-direction: column; gap: 6px; }
.cthd-modal .cthd-rinkrow { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border: 1px solid var(--dg-border); border-radius: var(--dg-radius); font: 500 14px/1 var(--dg-font); cursor: pointer; }
.cthd-modal .cthd-rinkrow:hover { background: var(--dg-accent); }
.cthd-modal input.cthd-check { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; margin: 0; flex: none; border: 1px solid var(--dg-input); border-radius: 4px; background: var(--dg-input-bg); box-shadow: var(--dg-shadow-xs); display: grid; place-items: center; cursor: pointer; }
.cthd-modal input.cthd-check:checked { background: var(--dg-primary); border-color: var(--dg-primary); }
.cthd-modal input.cthd-check:checked::after { content: ''; width: 9px; height: 5px; border: 2px solid var(--dg-primary-fg); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.cthd-modal input.cthd-check:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in oklab, var(--dg-ring) 50%, transparent); }
.cthd-modal .cthd-guide { max-height: 65vh; overflow-y: auto; font-size: 14px; }

/* CTH Diagrams: the page shell (tree, top bar, dialogs, toasts, embeds).
   web/styles.css (the editor, library and shadcn recipes) is concatenated in
   front of this file by build-web.mjs. It reads a few Obsidian-named variables
   (--background-primary, --text-normal ...) from when it was an Obsidian
   plugin; they are defined here. */

:root {
  --font-interface: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --background-primary: #ffffff;
  --text-normal: oklch(0.145 0 0);
  --text-muted: oklch(0.556 0 0);
  --layer-modal: 50;
  --tree-w: 272px;
}
body.theme-dark {
  --background-primary: oklch(0.145 0 0);
  --text-normal: oklch(0.985 0 0);
  --text-muted: oklch(0.708 0 0);
}
html, body { height: 100%; margin: 0; }
body { background: var(--background-primary); color: var(--text-normal); font-family: var(--font-interface); -webkit-font-smoothing: antialiased; overflow: hidden; }

/* ---- the shell --------------------------------------------------------------- */
.cthw-app { display: grid; grid-template-columns: var(--tree-w) minmax(0, 1fr); height: 100dvh; background: var(--dg-bg); }
.cthw-app.is-tree-closed, .cthw-app.is-disconnected { grid-template-columns: minmax(0, 1fr); }
.cthw-app.is-tree-closed .cthw-tree, .cthw-app.is-disconnected .cthw-tree { display: none; }
.cthw-main { min-width: 0; min-height: 0; height: 100dvh; overflow: hidden; position: relative; container-type: inline-size; container-name: cthd; }
.cthw-scrim { display: none; }

/* ---- the file tree ---------------------------------------------------------- */
.cthw-tree { position: relative; display: flex; flex-direction: column; min-height: 0; height: 100dvh; border-right: 1px solid var(--dg-border); background: var(--dg-card); }
/* drag the tree's right edge to resize it */
.cthw-tree-resize { position: absolute; top: 0; right: -4px; width: 8px; height: 100%; z-index: 5; cursor: col-resize; touch-action: none; }
.cthw-tree-resize::after { content: ''; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background-color 120ms; }
.cthw-tree-resize:hover::after, html.cthw-resizing .cthw-tree-resize::after { background: var(--dg-ring); }
html.cthw-resizing, html.cthw-resizing * { cursor: col-resize !important; user-select: none !important; }
.cthw-brand { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px 14px; }
.cthw-logo { display: inline-grid; place-items: center; width: 28px; height: 28px; background: transparent; color: var(--dg-fg); flex: none; } /* a plain line icon, like the favicon */
.cthw-logo svg { width: 22px; height: 22px; }
.cthw-logo.is-lg { width: 44px; height: 44px; border-radius: var(--dg-radius-lg); }
.cthw-logo.is-lg svg { width: 26px; height: 26px; }
.cthw-brand-name { font: 600 14px/1 var(--dg-font); }
.cthw-tree-actions { display: flex; gap: 6px; padding: 4px 12px 8px; }
.cthd .cthd-btn.cthw-grow-btn { flex: 1; }
.cthw-tree-searchwrap { margin: 0 12px 8px; }
.cthd .cthw-tree-searchwrap .cthd-input { width: 100%; }
.cthw-tree-list { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 6px 12px; overscroll-behavior: contain; scrollbar-width: thin; }
.cthw-row {
  display: flex; align-items: flex-start; gap: 6px; width: 100%; min-height: 30px; padding: 5px 8px; margin: 0;
  border: 0; border-radius: var(--dg-radius-sm); background: transparent; color: var(--dg-fg);
  font: 400 13px/20px var(--dg-font); text-align: left; cursor: pointer; user-select: none; outline: none;
}
.cthw-row:hover { background: var(--dg-accent); }
.cthw-row:focus-visible { box-shadow: 0 0 0 2px var(--dg-ring); }
.cthw-row.is-active { background: var(--dg-secondary); font-weight: 500; }
.cthw-row > .cthd-ic { display: inline-flex; align-items: center; height: 20px; flex: none; }
.cthw-row .cthd-ic svg { width: 15px; height: 15px; color: var(--dg-muted-fg); }
.cthw-row.is-active .cthd-ic svg { color: var(--dg-fg); }
.cthw-rootrow { margin: 0 6px 2px; width: calc(100% - 12px); font-weight: 500; }
.cthw-chev { display: inline-grid; place-items: center; width: 16px; height: 16px; margin: 2px 0; flex: none; border-radius: 4px; }
.cthw-chev:hover { background: var(--dg-muted); }
.cthw-chev .cthd-ic svg { width: 13px; height: 13px; }
.cthw-row-name { flex: 1; min-width: 0; overflow-wrap: anywhere; } /* long names wrap: no text is ever cut off */
.cthw-row-count { font: 400 11px/20px var(--dg-font); color: var(--dg-muted-fg); font-variant-numeric: tabular-nums; }
.cthw-tree-empty { padding: 10px 12px; font: 400 13px/1.4 var(--dg-font); color: var(--dg-muted-fg); }
.cthw-tree-foot { display: flex; align-items: center; justify-content: space-between; padding: 8px; border-top: 1px solid var(--dg-border); }
.cthw-dropping { box-shadow: inset 0 0 0 2px var(--dg-marquee) !important; background: var(--dg-marquee-soft) !important; }
.is-drag-source { opacity: 0.45; }
html.cthw-is-dragging .cthw-row:hover:not(.cthw-dropping) { background: transparent; }

/* ---- the editor page ---------------------------------------------------------- */
.cthw-doc { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.cthw-topbar { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 10px 12px 0; }
.cthw-topbar .cthd-crumbs { min-width: 0; }
/* the open diagram's (or folder's) name: click to rename it right there */
.cthd .cthd-crumb.is-current.is-renamable { cursor: text; }
.cthd .cthd-crumb.is-current.is-renamable:hover { background: var(--dg-accent); }
.cthd .cthw-name-input { height: 28px; padding: 0 8px; font: 600 14px/1 var(--dg-font); max-width: 100%; }
.cthd .cthd-side .cthw-name-input { flex: 1; width: auto; height: 32px; font-size: 15px; }
.cthw-doc .cthd-editor { flex: 1; min-height: 0; height: auto; }
.cthd-lib-left { min-width: 0; }

/* the card image is a thumbnail: fit it inside the card */
.cthd-card-pic.is-broken { background: var(--dg-muted); }
/* a sequence's card shows its first rink only, not every rink shrunk into the card */
.cthd .cthd-thumb.is-seq { height: auto; aspect-ratio: 2 / 1; top: 50%; transform: translateY(-50%); object-fit: cover; object-position: top; }

/* ---- connect ------------------------------------------------------------------ */
.cthw-connect { display: grid; place-items: center; height: 100%; overflow-y: auto; padding: 24px 16px; }
.cthw-connect-card { width: min(480px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 28px; background: var(--dg-card); border: 1px solid var(--dg-border); border-radius: var(--dg-radius-xl); box-shadow: var(--dg-shadow-sm); }
.cthw-connect-card h1 { margin: 4px 0 0; font: 600 22px/1.2 var(--dg-font); }
.cthw-steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; font: 400 13px/1.5 var(--dg-font); }
.cthw-steps code { font: 500 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--dg-muted); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.cthw-steps a, .cthw-guide a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ---- dialogs ------------------------------------------------------------------ */
.cthw-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgb(0 0 0 / 0.5); animation: cthw-fade 120ms ease-out; }
.cthw-modal { width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 22px; background: var(--dg-bg); color: var(--dg-fg); border: 1px solid var(--dg-border); border-radius: var(--dg-radius-lg); box-shadow: var(--dg-shadow-lg); outline: none; font-family: var(--dg-font); }
.cthw-modal.is-wide { width: min(640px, 100%); }
.cthw-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cthw-modal-title { margin: 0; font: 600 18px/1.3 var(--dg-font); }
.cthw-modal-content { display: flex; flex-direction: column; gap: 10px; }
.cthw-modal .cthd-modal-desc { margin: -6px 0 0; font: 400 14px/1.45 var(--dg-font); color: var(--dg-muted-fg); }
.cthw-modal .cthd-modal-footer { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.cthw-picklist { display: flex; flex-direction: column; gap: 2px; max-height: 50dvh; overflow-y: auto; }
.cthw-pickrow { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border: 0; border-radius: var(--dg-radius-sm); background: transparent; color: var(--dg-fg); font: 400 14px/1 var(--dg-font); text-align: left; cursor: pointer; }
.cthw-pickrow:hover, .cthw-pickrow.is-active { background: var(--dg-accent); }
.cthw-set-sec { display: flex; flex-direction: column; gap: 10px; padding: 12px 0; border-top: 1px solid var(--dg-border); }
.cthw-set-sec:first-child { border-top: 0; padding-top: 0; }
.cthw-set-title { font: 600 13px/1 var(--dg-font); color: var(--dg-muted-fg); text-transform: uppercase; letter-spacing: .04em; }
.cthw-set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.cthw-set-label { font: 500 14px/1.3 var(--dg-font); }
.cthw-set-row .cthw-text { width: min(300px, 55%); }
.cthw-select { width: auto; min-width: 180px; height: 36px; }
.cthw-guide h2, .cthw-guide h3, .cthw-guide h4 { margin: 12px 0 4px; font-family: var(--dg-font); }
.cthw-guide p, .cthw-guide li { font: 400 14px/1.55 var(--dg-font); }

/* ---- menus and toasts ---------------------------------------------------------- */
.cthw-menu { position: fixed; z-index: 120; min-width: 200px; padding: 4px; background: var(--dg-popover); color: var(--dg-fg); border: 1px solid var(--dg-border); border-radius: var(--dg-radius); box-shadow: var(--dg-shadow-md); font-family: var(--dg-font); }
.cthw-menu-item { display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 8px; border: 0; border-radius: var(--dg-radius-sm); background: transparent; color: inherit; font: 400 14px/1 var(--dg-font); text-align: left; cursor: pointer; }
.cthw-menu-item:hover, .cthw-menu-item:focus-visible { background: var(--dg-accent); outline: none; }
.cthw-menu-item .cthd-ic { width: 16px; }
.cthw-menu-item.is-danger { color: var(--dg-destructive); }
.cthw-menu-sep { height: 1px; margin: 4px -4px; background: var(--dg-border); }
.cthw-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 130; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.cthw-toast { padding: 12px 14px; background: var(--dg-popover, #fff); color: var(--dg-fg, #111); border: 1px solid var(--dg-border, #e5e5e5); border-radius: var(--dg-radius, 8px); box-shadow: var(--dg-shadow-lg); font: 400 14px/1.45 var(--font-interface); animation: cthw-rise 160ms ease-out; cursor: default; }
.cthw-toast.is-out { opacity: 0; transform: translateY(4px); transition: opacity 180ms, transform 180ms; }
body.theme-dark .cthw-toast { border-color: oklch(1 0 0 / 10%); }
@keyframes cthw-fade { from { opacity: 0; } }
@keyframes cthw-rise { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .cthw-overlay, .cthw-toast { animation: none; } }

/* ---- phones and narrow windows: the tree is a drawer --------------------------- */
@media (max-width: 800px) {
  .cthw-app, .cthw-app.is-tree-closed { grid-template-columns: minmax(0, 1fr); }
  .cthw-app .cthw-tree, .cthw-app.is-tree-closed .cthw-tree { display: flex; position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 60; transform: translateX(-102%); transition: transform 180ms ease; box-shadow: var(--dg-shadow-lg); }
  .cthw-app.is-drawer-open .cthw-tree { transform: none; }
  .cthw-app.is-drawer-open .cthw-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgb(0 0 0 / 0.4); }
  .cthw-app.is-disconnected .cthw-tree { display: none; }
  .cthd-lib-toolbar { padding: 10px 12px; }
  .cthd-lib-body { padding: 12px; }
  .cthw-set-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .cthw-set-row .cthw-text, .cthw-select { width: 100%; }
}

/* ---- polish ---------------------------------------------------------------------- */
.cthw-modal .cthd-hint { margin: 2px 0 0; font: 400 12px/1.45 var(--dg-font); color: var(--dg-muted-fg); }
.cthw-set-row > :first-child { min-width: 0; flex: 1; }
.cthw-set-row > :last-child { flex: none; }
.cthw-set-row .cthw-text, .cthw-set-row .cthw-select { width: 280px; }
.cthw-set-row .cthd-row { justify-content: flex-end; flex-wrap: wrap; }
.cthd-fact .v { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 800px) {
  .cthd-lib-right { width: 100%; }
  .cthd-lib-right .cthd-search { flex: 1 1 100%; }
  .cthd-lib-right .cthd-search .cthd-input { width: 100%; }
  .cthd-lib-right > .cthd-btn.is-default { margin-left: auto; }
  .cthw-set-row .cthw-text, .cthw-set-row .cthw-select { width: 100%; }
}
/* menus and toasts borrow .cthd-layer for its tokens, not its zero-size box */
.cthw-menu.cthd-layer { width: auto; height: auto; }
.cthw-toasts.cthd-layer { top: auto; left: auto; width: auto; height: auto; z-index: 130; }

.cthw-other { font: 400 13px/1.5 var(--dg-font); color: var(--dg-muted-fg); }
.cthw-other summary { cursor: pointer; }
.cthw-other[open] { display: grid; gap: 8px; }
.cthw-other code { font: 500 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--dg-muted); padding: 1px 5px; border-radius: 4px; word-break: break-all; }

/* ---- the status pill (offline, signed out, changes waiting) ---------------------- */
.cthw-banner { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 95; display: flex; align-items: center; gap: 10px; max-width: min(640px, calc(100vw - 24px)); padding: 8px 10px 8px 14px; background: var(--dg-popover); color: var(--dg-fg); border: 1px solid var(--dg-border); border-radius: 999px; box-shadow: var(--dg-shadow-lg); font: 500 13px/1.35 var(--dg-font); }
.cthw-banner.is-hidden { display: none; }
.cthw-banner .cthd-ic svg { width: 15px; height: 15px; }
.cthw-banner-btn { flex: none; height: 28px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--dg-primary); color: var(--dg-primary-fg); font: 500 13px/1 var(--dg-font); cursor: pointer; }
.cthd .cthd-status.is-kept { background: color-mix(in oklab, oklch(0.769 0.188 70.08) 22%, transparent); }
.cthd .cthd-btn.is-spinning svg { animation: cthw-spin 700ms linear infinite; }
@keyframes cthw-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .cthd .cthd-btn.is-spinning svg { animation: none; } }

/* ---- inside a Notion embed -------------------------------------------------------- */
/* the page around the embed keeps scrolling once a list inside reaches its end */
html.cthw-embed .cthd-lib-body, html.cthw-embed .cthw-tree-list, html.cthw-embed .cthd-side { overscroll-behavior: auto; }
html.cthw-embed .cthw-connect { padding: 12px; }
html.cthw-embed .cthw-connect-card { padding: 20px; gap: 10px; }
.cthw-embed-wait { display: grid; gap: 10px; }
.cthw-embed-wait .cthd-row .cthd-input { flex: 1; }
.cthw-embed-wait a, .cthw-warn a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.cthw-linkbtn { border: 0; padding: 0; background: none; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.cthw-warn { padding: 8px 10px; border-radius: var(--dg-radius); background: var(--dg-muted); }
.cthw-code { display: block; padding: 12px; border-radius: var(--dg-radius); background: var(--dg-muted); font: 600 15px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; user-select: all; }
.cthw-toast-btn { margin-left: 6px; border: 0; padding: 0; background: none; color: inherit; font: 600 14px/1.4 var(--font-interface); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* In a Notion embed, Notion shows its own buttons in the top right corner on
   hover: keep the top bars' buttons clear of them. */
html.cthw-embed .cthw-topbar, html.cthw-embed .cthd-lib-toolbar { padding-right: 132px; }
@media (max-width: 560px) { html.cthw-embed .cthw-topbar, html.cthw-embed .cthd-lib-toolbar { padding-right: 12px; padding-top: 40px; } }
/* dark mode's lighter red is too pale behind white text: use the deeper red */
body.theme-dark .cthd .cthd-btn.is-destructive, body.theme-dark .cthd-modal .cthd-btn.is-destructive { background: oklch(0.577 0.245 27.325); }

/* the editor's top bar: every action lives here (no details panel) */
.cthw-topbar { flex-wrap: wrap; row-gap: 4px; }
.cthw-topbar .cthd-btn.is-danger:not(:hover) { color: var(--dg-muted-fg); }
.cthw-topbar-sep { width: 1px; height: 20px; margin: 0 2px; background: var(--dg-border); flex: none; }
.cthw-rink-badge { flex: none; }

/* the action rail: a slim column on the editor's right edge */
.cthw-docbody { flex: 1; min-height: 0; display: flex; }
.cthw-docbody > .cthd-editor { flex: 1; min-width: 0; min-height: 0; height: auto; }
.cthw-rail { flex: none; width: 44px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; overflow-y: auto; scrollbar-width: none; border-left: 1px solid var(--dg-border); background: var(--dg-bg); }
.cthw-rail::-webkit-scrollbar { display: none; }
.cthd .cthw-rail .cthd-btn.is-danger:not(:hover) { color: var(--dg-muted-fg); }
.cthw-rail-sep { width: 20px; height: 1px; margin: 4px 0; background: var(--dg-border); flex: none; }
.cthw-rink-badge { flex: none; margin: 2px 0 4px; padding: 2px 6px; border: 1px solid var(--dg-border); border-radius: 999px; font: 600 11px/1.3 var(--dg-font); color: var(--dg-fg); font-variant-numeric: tabular-nums; cursor: default; }
/* shadcn Tooltip: instant, dark, to the left of the button */
.cthw-tip { position: fixed; z-index: 200; max-width: 240px; padding: 6px 10px; border-radius: var(--dg-radius-sm, 6px); background: var(--dg-primary); color: var(--dg-primary-fg); font: 500 12px/1.35 var(--dg-font); pointer-events: none; opacity: 0; transform: translateX(4px); transition: opacity 80ms ease-out, transform 80ms ease-out; box-shadow: var(--dg-shadow-md); }
.cthw-tip.is-on { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .cthw-tip { transition: none; } }
.cthw-logo svg { stroke-width: 1.75; } /* the CTH line style (black-175) */

/* CTH Mindmaps: the editor (canvas, toolbar, zoom, minimap, find, outline,
   popovers). Concatenated after web/styles.css and web/web.css by
   build-web.mjs. The CANVAS is the map's own background (--mm-bg, set from
   the map's theme): a map's look is content and never follows the app's
   light or dark mode. Chrome drawn over it (selection, drop marks) is the
   cyan --dg-marquee, as in CTH Diagrams. */

.mm-host { flex: 1; min-width: 0; min-height: 0; display: flex; }
.mm-wrap { flex: 1; min-width: 0; min-height: 0; display: flex; }
.mm-stage { position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden; background-color: var(--mm-bg, #fff); }
.mm-stage[data-canvas="dots"] { background-image: radial-gradient(circle, var(--mm-dot) 1px, transparent 1.2px); background-size: var(--mm-grid) var(--mm-grid); background-position: var(--mm-gx) var(--mm-gy); }
.mm-stage[data-canvas="grid"] { background-image: linear-gradient(var(--mm-dot) 1px, transparent 1px), linear-gradient(90deg, var(--mm-dot) 1px, transparent 1px); background-size: var(--mm-grid) var(--mm-grid); background-position: var(--mm-gx) var(--mm-gy); }
.mm-canvas { position: absolute; inset: 0; outline: none; touch-action: none; cursor: default; user-select: none; -webkit-user-select: none; }
.mm-canvas.is-panning, .mm-canvas.is-space { cursor: grabbing; }
.mm-canvas.is-space:not(.is-panning) { cursor: grab; }
.mm-canvas.is-dragging { cursor: grabbing; }
.mm-canvas.is-copying { cursor: copy; }
.mm-svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* topics */
.mm-node, .mm-edges path, .mm-rel { transition: opacity 120ms ease-out; }
.mm-node.is-fade, .mm-edges path.is-fade, .mm-rel.is-fade { opacity: 0.14; }
.mm-glabel { opacity: var(--mm-label-o, 1); }
.mm-node.is-hl .mm-glabel, .mm-node.is-dot:hover .mm-glabel { opacity: 1; }
.mm-node.is-dot:hover .mm-shape { stroke: var(--dg-marquee); stroke-width: 2; }
.mm-node { cursor: pointer; }
.mm-node.is-dim { opacity: 0.3; }
.mm-task, .mm-ic, .mm-badge { cursor: pointer; }
.mm-ic:hover > g { opacity: 0.7; }
.mm-badge:hover rect { stroke-width: 2.2; }
.mm-rel { cursor: pointer; }
.mm-rel.is-sel .mm-rel-line { stroke: var(--dg-marquee); stroke-width: 2.4; }

/* selection chrome, drop marks, hover buttons (the UI layer) */
.mm-sel-ring { fill: none; stroke: var(--dg-marquee); stroke-width: 2.25; pointer-events: none; }
.mm-find-ring { fill: none; stroke: #f59e0b; stroke-width: 1.75; stroke-dasharray: 4 3; pointer-events: none; }
.mm-find-ring.is-current { stroke-width: 2.75; stroke-dasharray: none; }
.mm-drop-ring { fill: var(--dg-marquee-soft); stroke: var(--dg-marquee); stroke-width: 2.5; pointer-events: none; }
.mm-drop-line { stroke: var(--dg-marquee); stroke-width: 4; stroke-linecap: round; pointer-events: none; }
.mm-ghost { opacity: 0.85; pointer-events: none; }
.mm-ghost rect { stroke: var(--dg-marquee); stroke-width: 2; }
.mm-marquee { fill: var(--dg-marquee-soft); stroke: var(--dg-marquee); stroke-width: 1.5; stroke-dasharray: 5 4; pointer-events: none; }
.mm-connect { stroke: var(--dg-marquee); stroke-width: 2; stroke-dasharray: 6 5; fill: none; pointer-events: none; }
.mm-uibtn { cursor: pointer; }
.mm-uibtn circle { fill: #ffffff; stroke: #a1a1aa; stroke-width: 1.25; }
.mm-uibtn path { stroke: #52525b; stroke-width: 1.75; stroke-linecap: round; fill: none; }
.mm-uibtn:hover circle { fill: var(--dg-marquee); stroke: var(--dg-marquee); }
.mm-uibtn:hover path { stroke: #0a0a0a; }
.mm-uibtn.is-add circle { fill: var(--dg-marquee); stroke: var(--dg-marquee); }
.mm-uibtn.is-add path { stroke: #0a0a0a; }
.mm-stage.is-darkmap .mm-uibtn circle { fill: #27272a; stroke: #52525b; }
.mm-stage.is-darkmap .mm-uibtn path { stroke: #e4e4e7; }
.mm-stage.is-darkmap .mm-uibtn.is-add circle, .mm-stage.is-darkmap .mm-uibtn:hover circle { fill: var(--dg-marquee); stroke: var(--dg-marquee); }
.mm-stage.is-darkmap .mm-uibtn.is-add path, .mm-stage.is-darkmap .mm-uibtn:hover path { stroke: #0a0a0a; }

/* typing in a topic: a bare textarea exactly over the topic's text */
.mm-edit {
  position: absolute; z-index: 4; margin: 0; padding: 0 3px; border: 0; outline: none; resize: none; overflow: hidden;
  background: transparent; text-align: center; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: none;
}

/* the context toolbar: bottom centre, one row, scrolls sideways when narrow */
.mm-bar, .mm-zoom, .mm-find, .mm-crumbs, .mm-hint {
  position: absolute; z-index: 5; display: flex; align-items: center; gap: 2px;
  background: color-mix(in oklab, var(--dg-popover) 94%, transparent); color: var(--dg-fg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--dg-border); border-radius: var(--dg-radius-lg); box-shadow: var(--dg-shadow-md);
}
.mm-bar { left: 50%; bottom: 14px; transform: translateX(-50%); max-width: calc(100% - 24px); padding: 4px; overflow-x: auto; scrollbar-width: none; }
.mm-bar::-webkit-scrollbar { display: none; }
.mm-bar[hidden] { display: none; }
.mm-bar.is-raised { bottom: 58px; }
.mm-bar-note { padding: 0 8px 0 10px; font: 500 13px/1 var(--dg-font); color: var(--dg-muted-fg); white-space: nowrap; }
.mm-tb-btn {
  flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; margin: 0;
  border: 0; border-radius: var(--dg-radius); background: transparent; color: color-mix(in oklab, var(--dg-fg) 78%, transparent);
  cursor: pointer; transition: background-color var(--dg-dur), color var(--dg-dur);
}
.mm-tb-btn svg { width: 18px; height: 18px; stroke-width: 1.9; }
.mm-tb-btn.is-glyph { width: 44px; }
.mm-tb-btn.is-glyph svg { width: 32px; height: 22px; stroke-width: 1.6; }
.mm-tb-btn.is-flipped svg { transform: scaleY(-1); }
.mm-tb-btn:hover { background: var(--dg-accent); color: var(--dg-fg); }
.mm-tb-btn.is-on { background: var(--dg-secondary); color: var(--dg-fg); box-shadow: inset 0 0 0 1px var(--dg-border); }
.mm-tb-btn.is-danger:hover { color: var(--dg-destructive); background: color-mix(in oklab, var(--dg-destructive) 10%, transparent); }
.mm-tb-btn:disabled { opacity: 0.35; cursor: default; background: transparent; }
.mm-tb-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dg-marquee); }
.mm-tb-sep { flex: none; width: 1px; height: 22px; margin: 0 3px; background: var(--dg-border); }
.mm-tb-color { width: 18px; height: 18px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.18); }

/* zoom (bottom left), minimap (bottom right), find and focus (top left), hints (top centre) */
.mm-zoom { left: 12px; bottom: 14px; padding: 3px; }
.mm-zoom .mm-tb-btn { width: 30px; height: 30px; }
.mm-zoom-pct { min-width: 50px; height: 30px; padding: 0 6px; border: 0; border-radius: var(--dg-radius); background: transparent; color: var(--dg-fg); font: 500 12px/1 var(--dg-font); font-variant-numeric: tabular-nums; cursor: pointer; }
.mm-zoom-pct:hover { background: var(--dg-accent); }
.mm-mini { position: absolute; z-index: 4; right: 12px; bottom: 14px; width: 176px; height: 120px; border: 1px solid var(--dg-border); border-radius: var(--dg-radius); box-shadow: var(--dg-shadow-sm); cursor: crosshair; background: var(--mm-bg); }
.mm-mini[hidden] { display: none; }
.mm-find { left: 12px; top: 12px; padding: 4px 4px 4px 10px; gap: 4px; }
.mm-find[hidden], .mm-crumbs[hidden], .mm-hint[hidden] { display: none; }
.mm-find > .cthd-ic svg { width: 15px; height: 15px; color: var(--dg-muted-fg); }
.cthd .mm-find .mm-find-input { width: 220px; height: 30px; border: 0; box-shadow: none; padding: 0 4px; background: transparent; }
.cthd .mm-find .mm-find-input:focus { box-shadow: none; }
.mm-find-count { min-width: 64px; font: 400 12px/1 var(--dg-font); color: var(--dg-muted-fg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mm-find .mm-tb-btn { width: 30px; height: 30px; }
.mm-crumbs { left: 12px; top: 12px; padding: 3px 3px 3px 10px; gap: 4px; max-width: calc(100% - 180px); overflow-x: auto; scrollbar-width: none; }
.mm-find:not([hidden]) ~ .mm-crumbs, .mm-crumbs:not([hidden]) ~ .mm-find { top: 58px; }
.mm-crumbs > .cthd-ic svg { width: 15px; height: 15px; color: var(--dg-marquee); }
.mm-crumb { flex: none; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; height: 26px; padding: 0 6px; border: 0; border-radius: var(--dg-radius-sm); background: none; color: var(--dg-muted-fg); font: 400 13px/26px var(--dg-font); cursor: pointer; }
.mm-crumb:hover { color: var(--dg-fg); background: var(--dg-accent); }
.mm-crumb.is-current { color: var(--dg-fg); font-weight: 600; cursor: default; background: none; }
.mm-crumb-sep { color: var(--dg-muted-fg); font-size: 12px; }
.mm-crumbs .mm-tb-btn { width: 28px; height: 28px; }
.mm-hint { left: 50%; top: 12px; transform: translateX(-50%); padding: 7px 12px; font: 500 13px/1.3 var(--dg-font); pointer-events: none; white-space: nowrap; }
/* in a Notion embed, Notion's own hover buttons sit in the top right: stay clear */
html.cthw-embed .mm-hint { top: 44px; }

/* locked: a quiet ring says view only */
.mm-stage.is-locked .mm-node { cursor: default; }
.mm-stage.is-locked .mm-bar { gap: 4px; }

/* popovers above the toolbar */
.mm-pop.cthd-layer { width: auto; height: auto; position: fixed; z-index: 140; min-width: 200px; max-width: min(420px, calc(100vw - 16px)); padding: 10px; background: var(--dg-popover); color: var(--dg-fg); border: 1px solid var(--dg-border); border-radius: var(--dg-radius-lg); box-shadow: var(--dg-shadow-lg); font-family: var(--dg-font); display: grid; gap: 8px; }
.mm-pop-title { font: 500 12px/1.2 var(--dg-font); color: var(--dg-muted-fg); padding: 0 2px; }
.mm-pop-grid { display: grid; gap: 4px; }
.mm-choice { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 36px; padding: 7px 6px; border: 1px solid transparent; border-radius: var(--dg-radius); background: transparent; color: var(--dg-fg); cursor: pointer; font: 500 12px/1.2 var(--dg-font); text-align: center; }
.mm-choice svg { color: color-mix(in oklab, var(--dg-fg) 80%, transparent); }
.mm-choice:hover { background: var(--dg-accent); }
.mm-choice.is-on { border-color: var(--dg-ring); background: var(--dg-secondary); }
.mm-choice:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dg-marquee); }
.mm-choice-label { max-width: 100%; }
.mm-choice.is-text { min-height: 34px; font-size: 13px; }
.mm-colors { display: grid; grid-template-columns: repeat(7, 28px); gap: 6px; }
.mm-color { width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 0; background: var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.15); cursor: pointer; display: grid; place-items: center; color: var(--dg-muted-fg); }
.mm-color:not([style*="#"]) { background: var(--dg-muted); }
.mm-color .cthd-ic svg { width: 14px; height: 14px; }
.mm-color.is-on { box-shadow: 0 0 0 2px var(--dg-popover), 0 0 0 4px var(--dg-marquee); }
.mm-color:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dg-popover), 0 0 0 4px var(--dg-ring); }
.mm-theme-chip { display: flex; gap: 3px; padding: 6px 7px; border: 1px solid; border-radius: 6px; }
.mm-theme-chip i { width: 9px; height: 9px; border-radius: 50%; }

/* the bubble map panel: forces as sliders */
.mm-force { display: grid; grid-template-columns: 124px minmax(0, 1fr) 36px; align-items: center; gap: 8px; font: 500 12px/1.2 var(--dg-font); color: var(--dg-fg); }
.mm-force-val { text-align: right; color: var(--dg-muted-fg); font-variant-numeric: tabular-nums; }
.mm-range { width: 100%; accent-color: var(--dg-primary); cursor: pointer; }
.mm-pop-row { display: flex; gap: 4px; flex-wrap: wrap; }
.mm-pop-row .mm-choice { flex: 1; }
@media (prefers-reduced-motion: reduce) { .mm-node, .mm-edges path, .mm-rel { transition: none; } }

/* the note shown when resting on a note icon */
.mm-notetip.cthd-layer { width: auto; height: auto; position: fixed; z-index: 150; max-width: 300px; padding: 8px 10px; background: var(--dg-popover); color: var(--dg-fg); border: 1px solid var(--dg-border); border-radius: var(--dg-radius); box-shadow: var(--dg-shadow-md); font: 400 13px/1.45 var(--dg-font); white-space: pre-wrap; pointer-events: none; opacity: 0; transition: opacity 80ms; }
.mm-notetip.is-on { opacity: 1; }
.mm-tip { transform: translateY(4px); }
.mm-tip.is-on { transform: none; }

/* the outline panel (right of the canvas) */
.mm-outline { flex: none; width: 300px; display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--dg-border); background: var(--dg-bg); }
.mm-outline[hidden] { display: none; }
.mm-ol-head { display: flex; align-items: center; gap: 8px; padding: 8px 6px 8px 14px; border-bottom: 1px solid var(--dg-border); font: 600 13px/1 var(--dg-font); }
.mm-ol-head .mm-tb-btn { width: 28px; height: 28px; margin-left: auto; }
.mm-ol-count { font: 400 12px/1 var(--dg-font); color: var(--dg-muted-fg); }
.mm-ol-list { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 6px 16px; overscroll-behavior: contain; }
.mm-ol-sec { margin: 12px 8px 4px; font: 500 11px/1 var(--dg-font); color: var(--dg-muted-fg); text-transform: uppercase; letter-spacing: .04em; }
.mm-ol-row { display: flex; align-items: flex-start; gap: 4px; min-height: 28px; padding: 4px 8px; border-radius: var(--dg-radius-sm); font: 400 13px/20px var(--dg-font); cursor: pointer; user-select: none; }
.mm-ol-row:hover { background: var(--dg-accent); }
.mm-ol-row.is-sel { background: var(--dg-secondary); box-shadow: inset 2px 0 0 var(--dg-marquee); }
.mm-ol-chev { flex: none; display: inline-grid; place-items: center; width: 18px; height: 20px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--dg-muted-fg); cursor: pointer; }
.mm-ol-chev:hover { background: var(--dg-muted); }
.mm-ol-chev svg { width: 13px; height: 13px; }
.mm-ol-task { flex: none; width: 13px; height: 13px; margin: 3.5px 2px 0; border: 1.5px solid var(--dg-muted-fg); border-radius: 3px; }
.mm-ol-task.is-done { background: var(--dg-muted-fg); }
.mm-ol-text { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.mm-ol-text.is-done { text-decoration: line-through; color: var(--dg-muted-fg); }
.mm-ol-text.is-empty { color: var(--dg-muted-fg); }
.mm-ol-ic { margin-top: 3px; }
.mm-ol-ic svg { width: 13px; height: 13px; color: var(--dg-muted-fg); }

/* narrow panes (a small Notion embed, a phone) */
@container cthd (max-width: 640px) {
  .mm-outline { position: absolute; right: 44px; top: 0; bottom: 0; z-index: 8; width: min(300px, calc(100% - 60px)); box-shadow: var(--dg-shadow-lg); }
  .mm-zoom .mm-zoom-pct { display: none; }
  .mm-bar { max-width: calc(100% - 16px); }
  .mm-crumbs { max-width: calc(100% - 24px); }
  .cthd .mm-find .mm-find-input { width: 130px; }
}
@media (prefers-reduced-motion: reduce) { .mm-notetip { transition: none; } }

/* ---- shell pieces this app adds ---------------------------------------------------- */
.cthw-menu-label { flex: 1; }
.cthw-menu-hint { margin-left: 16px; font: 400 12px/1 var(--dg-font); color: var(--dg-muted-fg); }
.cthw-menu-item:disabled { opacity: .45; pointer-events: none; }
.cthd-modal .cthw-textarea, .cthw-modal .cthw-textarea { height: auto; min-height: 180px; padding: 10px 12px; resize: vertical; font: 400 14px/1.5 var(--dg-font); }
.cthw-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.cthw-template { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 84px; padding: 12px; border: 1px solid var(--dg-border); border-radius: var(--dg-radius-lg); background: var(--dg-card); color: var(--dg-fg); text-align: left; cursor: pointer; font-family: var(--dg-font); }
.cthw-template:hover { background: var(--dg-accent); }
.cthw-template:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in oklab, var(--dg-ring) 50%, transparent); }
.cthw-template.is-default { border-color: var(--dg-ring); }
.cthw-template.is-paste { border-style: dashed; }
.cthw-template-name { font: 600 14px/1.3 var(--dg-font); }
.cthw-template-desc { font: 400 12px/1.4 var(--dg-font); color: var(--dg-muted-fg); }
.cthw-template-tag { margin-top: auto; font: 500 11px/1 var(--dg-font); color: var(--dg-muted-fg); }
.cthw-modal .cthd-grow { flex: 1; }
.cthd-card-pic { background: #fff; }
.cthd .cthd-thumb { left: 6px; top: 6px; width: calc(100% - 12px); height: calc(100% - 12px); }
.cthw-rail .cthd-btn.is-secondary { box-shadow: inset 0 0 0 1px var(--dg-border); }
