/* Application palette. Component rules are shared by both appearances. */
:root {
  --app-font: 14px/1.35 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --app-background: #fff;
  --app-surface: #fff;
  --app-subtle: #f5f7fa;
  --app-foreground: #273444;
  --app-muted: #63728a;
  --app-border: #cbd3de;
  --app-hover: #edf2f8;
  --app-accent: #286ab3;
  --app-focus-ring: #78a9ed;
  --app-disabled-text: #8993a1;
  --app-primary: #2769b2;
  --app-primary-hover: #18528f;
  --app-primary-disabled: #b7c4d4;
  --app-on-primary: #fff;
  --app-selection: #e8f0fc;
  --app-selection-border: #b8cdeb;
  --app-selection-text: #205c9b;
  --app-danger: #a33636;
  --app-danger-surface: #fff1f0;
  --app-danger-border: #e5b8b4;
  --app-danger-fill: #b84339;
  --app-success: #267044;
  --app-success-fill: #37805b;
  --app-warning-surface: #fffbf2;
  --app-warning-border: #e5d5b4;
  --app-run-backdrop: rgba(247, 249, 252, .92);
  --app-modal-backdrop: rgba(25, 38, 55, .4);
  --app-control-radius: 6px;
  --app-control-height: 30px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --app-background: #171b22;
  --app-surface: #232a35;
  --app-subtle: #293241;
  --app-foreground: #e5eaf1;
  --app-muted: #a8b3c2;
  --app-border: #465365;
  --app-hover: #354660;
  --app-accent: #85b7ff;
  --app-focus-ring: #85b7ff;
  --app-primary-disabled: #3b506b;
  --app-selection: #354660;
  --app-selection-border: #526b8e;
  --app-selection-text: #c2dbff;
  --app-danger: #ffaaa3;
  --app-danger-surface: #42292e;
  --app-danger-border: #754b50;
  --app-success: #8ad0a6;
  --app-warning-surface: #373123;
  --app-warning-border: #716243;
  --app-run-backdrop: rgba(17, 21, 28, .92);
  --app-modal-backdrop: rgba(8, 12, 18, .6);
  color-scheme: dark;
}

/* Only public properties cross the library boundary. This common ancestor owns
   the plot, editor, selection toolbar and chart-mounted floating controls. */
.clinker-plot-workspace {
  --cm-background: var(--app-background);
  --cm-surface: var(--app-surface);
  --cm-subtle: var(--app-subtle);
  --cm-hover: var(--app-hover);
  --cm-foreground: var(--app-foreground);
  --cm-muted: var(--app-muted);
  --cm-border: var(--app-border);
  --cm-accent: var(--app-accent);
  --cm-focus-ring: var(--app-focus-ring);
  --cm-selection: var(--app-selection);
  --cm-danger: var(--app-danger);
  --cm-font: 13px/1.4 system-ui, sans-serif;
  --cm-control-height: var(--app-control-height);
  --cm-control-radius: var(--app-control-radius);
  background: var(--app-background);
}

:root {
  --input-row-height: 40px;
  --input-row-padding: 5px;
  color: var(--app-foreground);
  font: var(--app-font);
  background: var(--app-background);
}
:where(.clinker-app) * { box-sizing: border-box; }
html,
.clinker-app {
  width: 100%;
  height: 100%;
  margin: 0;
}
.clinker-app {
  --cm-background: var(--app-background);
  --cm-surface: var(--app-surface);
  --cm-subtle: var(--app-subtle);
  --cm-hover: var(--app-hover);
  --cm-foreground: var(--app-foreground);
  --cm-muted: var(--app-muted);
  --cm-border: var(--app-border);
  --cm-accent: var(--app-accent);
  --cm-focus-ring: var(--app-focus-ring);
  --cm-selection: var(--app-selection);
  --cm-danger: var(--app-danger);
  --cm-font: var(--app-font);
  --cm-control-height: var(--app-control-height);
  --cm-control-radius: var(--app-control-radius);
  overflow: hidden;
}
:where(.clinker-app) [hidden] { display: none !important; }
:where(.clinker-app) .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* Page layout. */
:where(.clinker-app) .app-main {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex-direction: column;
}

/* Shared controls. */
:where(.clinker-app) .app-button,
:where(.clinker-app) .menu > .app-disclosure {
  min-height: var(--app-control-height);
  border: 1px solid var(--app-border);
  border-radius: var(--app-control-radius);
  padding: 4px 9px;
  background: var(--app-surface);
  color: inherit;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
}
:where(.clinker-app) label.app-button {
  display: inline-flex;
  align-items: center;
}
:where(.clinker-app) .app-button:focus-visible,
:where(.clinker-app) .app-button:has(input:focus-visible),
:where(.clinker-app) .app-field:focus-visible,
:where(.clinker-app) .app-disclosure:focus-visible {
  outline: 2px solid var(--app-focus-ring);
  outline-offset: 1px;
}
:where(.clinker-app) .app-button:disabled,
:where(.clinker-app) .app-button:has(input:disabled) {
  color: var(--app-disabled-text);
  background: var(--app-subtle);
  cursor: default;
}
:where(.clinker-app) .app-button.primary-action {
  border-color: var(--app-primary);
  background: var(--app-primary);
  color: var(--app-on-primary);
  font-weight: 600;
}
:where(.clinker-app) .app-button.primary-action:hover:not(:disabled) {
  border-color: var(--app-primary-hover);
  background: var(--app-primary-hover);
}
:where(.clinker-app) .app-button.primary-action:disabled {
  border-color: var(--app-primary-disabled);
  background: var(--app-primary-disabled);
}
:where(.clinker-app) .app-button.quiet-action {
  border-color: transparent;
  background: transparent;
  color: var(--app-accent);
}
:where(.clinker-app) .app-button.quiet-action:hover:not(:disabled) {
  border-color: transparent;
  background: var(--app-hover);
}
:where(.clinker-app) .app-button.quiet-action:disabled {
  background: transparent;
  color: var(--app-disabled-text);
}
:where(.clinker-app) .app-button.icon-button {
  display: grid;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  color: var(--app-muted);
  font-size: 1.5rem;
  line-height: 1;
}
:where(.clinker-app) .app-button.link-action {
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--app-accent);
  font-size: .9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
:where(.clinker-app) .app-field:where(select, textarea, input:not([type="checkbox"], [type="radio"], [type="file"])) {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-control-radius);
  padding: 8px;
  background: var(--app-surface);
  color: inherit;
  font: inherit;
}
:where(.clinker-app) .app-field:where([type="checkbox"], [type="radio"]) {
  width: 16px;
  height: 16px;
  flex: none;
  margin: 0;
  accent-color: var(--app-primary);
}
:where(.clinker-app) .app-field:disabled {
  background: var(--app-subtle);
  color: var(--app-disabled-text);
  cursor: default;
}
:where(.clinker-app) .app-field.flat-control {
  border: 0;
  border-radius: 4px;
  background: var(--app-subtle);
}
:where(.clinker-app) .app-button.compact-control,
:where(.clinker-app) .app-field.compact-control {
  min-height: 28px;
  padding: 3px 7px;
  font-size: inherit;
}
:where(.clinker-app) .app-button.large-control {
  min-height: 40px;
  padding: 8px 12px;
}
:where(.clinker-app) .app-button:hover:where(:not(:disabled):not(:has(input:disabled))),
:where(.clinker-app) .menu > .app-disclosure:hover,
:where(.clinker-app) .app-bar button[aria-expanded="true"],
:where(.clinker-app) .menu[open] > summary {
  border-color: var(--app-focus-ring);
  background: var(--app-hover);
}

/* Shared text and panels. */
:where(.clinker-app) .text-truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
:where(.clinker-app) .app-note {
  color: var(--app-muted);
  font-size: .8rem;
}
:where(.clinker-app) .app-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-surface);
}
:where(.clinker-app) .tree-matching-table { background: var(--app-subtle); }

/* Menus. */
:where(.clinker-app) .menu { position: relative; }
:where(.clinker-app) .menu summary {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
}
:where(.clinker-app) .menu summary::-webkit-details-marker { display: none; }
:where(.clinker-app) .menu > summary::after {
  content: "";
  box-sizing: border-box;
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  margin-top: -2px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
:where(.clinker-app) .menu[open] > summary::after {
  margin-top: 2px;
  transform: rotate(225deg);
}
:where(.clinker-app) .menu-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  display: grid;
  min-width: 170px;
  max-width: calc(100vw - 24px);
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-surface);
  box-shadow: 0 10px 30px rgba(23, 36, 54, .16);
}
:where(.clinker-app) .menu-end .menu-popover {
  right: 0;
  left: auto;
}
:where(.clinker-app) .menu-popover button {
  width: 100%;
  border-color: transparent;
  text-align: left;
}
:where(.clinker-app) .menu-popover button:hover:not(:disabled) { border-color: transparent; }
:where(.clinker-app) .menu-popover button[aria-pressed="true"]::after {
  content: "✓";
  float: right;
  margin-left: 16px;
  color: var(--app-accent);
}
:where(.clinker-app) .menu-checkbox { display: flex; align-items: center; gap: 7px; padding: 5px 8px; white-space: nowrap; }
:where(.clinker-app) .menu-section-divider { border-top: 1px solid var(--app-border); margin: 4px 0; }

/* Shared tables. */
:where(.clinker-app) .app-table {
  width: 100%;
  border-collapse: collapse;
}
:where(.clinker-app) .app-table :is(th, td) { text-align: left; }
:where(.clinker-app) .app-table thead th {
  background: var(--app-subtle);
  color: var(--app-muted);
  font-weight: 600;
}

/* Dialogs. */
:where(.clinker-app) .app-dialog {
  width: min(var(--dialog-width, 760px), calc(100vw - 32px));
  max-height: min(860px, calc(100dvh - 40px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--app-border);
  border-radius: 14px;
  background: var(--app-surface);
  color: var(--app-foreground);
  box-shadow: 0 20px 80px rgba(23, 36, 54, .24);
}
:where(.clinker-app) .compact-dialog { --dialog-width: 560px; }
:where(.clinker-app) .app-dialog[open] {
  display: flex;
  flex-direction: column;
}
:where(.clinker-app) .app-dialog::backdrop { background: var(--app-modal-backdrop); }
:where(.clinker-app) .app-dialog__actions {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--app-border);
}
:where(.clinker-app) .app-dialog form { margin: 0; }
:where(.clinker-app) .app-dialog__header {
  flex: none;
  padding: var(--dialog-header-padding, 14px 18px);
  border-bottom: 1px solid var(--app-border);
}
:where(.clinker-app) .app-dialog__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
:where(.clinker-app) .app-dialog__title {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -.025em;
}
:where(.clinker-app) .app-dialog__header p {
  margin: 5px 0 0;
  color: var(--app-muted);
}
:where(.clinker-app) .app-dialog__body {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: var(--dialog-body-padding, 16px 18px);
}
:where(.clinker-app) .app-dialog__body:focus-visible {
  outline: 2px solid var(--app-focus-ring);
  outline-offset: -3px;
}

/* Toolbar. */
:where(.clinker-app) .app-bar {
  position: relative;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  flex: none;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-surface);
  box-shadow: 0 1px 3px rgba(23, 36, 54, .04);
}
:where(.clinker-app) .app-logo {
  margin: 0 6px 0 0;
  color: var(--app-foreground);
  font-size: 1.5rem;
  line-height: 1;
  letter-spacing: -.045em;
}
:where(.clinker-app) .project-controls,
:where(.clinker-app) .app-actions,
:where(.clinker-app) .figure-menus,
:where(.clinker-app) .utility-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
:where(.clinker-app) .app-actions {
  flex: 1 0 auto;
  min-width: 0;
}
:where(.clinker-app) .utility-controls { margin-left: auto; }
:where(.clinker-app) .app-bar .menu > summary {
  min-height: 32px;
  border: 0;
  padding: 6px 9px;
  background: transparent;
}
:where(.clinker-app) .app-bar .menu > summary:hover,
:where(.clinker-app) .app-bar .menu[open] > summary { background: var(--app-hover); }
:where(.clinker-app) .app-bar .menu-popover button {
  min-height: 34px;
  border: 0;
  padding: 7px 10px;
  background: transparent;
}
:where(.clinker-app) .app-bar .menu-popover button:hover:not(:disabled) { background: var(--app-hover); }
:where(.clinker-app) .app-bar .menu-popover button:disabled {
  background: transparent;
  opacity: .45;
}
:where(.clinker-app) .file-menu .menu-popover { min-width: 250px; }
:where(.clinker-app) .data-menu .menu-popover { min-width: 260px; }
:where(.clinker-app) .order-menu .menu-popover { min-width: 245px; }
:where(.clinker-app) .menu-current-value { opacity: .75; }
:where(.clinker-app) .menu-caption { padding: 5px 10px 3px; font-size: .8rem; opacity: .65; }
:where(.clinker-app) .app-bar .edit-figure-action {
  flex: none;
  margin-left: auto;
  border-color: var(--app-selection-border);
  padding: 6px 12px;
  background: var(--app-selection);
  color: var(--app-selection-text);
  font-weight: 600;
}
:where(.clinker-app) .app-bar .about-button {
  display: grid;
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--app-muted);
  font-weight: 700;
}
@media (max-width: 900px) {
  :where(.clinker-app) .app-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 4px;
    padding: 7px 8px;
  }
  :where(.clinker-app) .project-controls {
    grid-column: 1;
    grid-row: 1;
  }
  :where(.clinker-app) .utility-controls {
    grid-column: 2;
    grid-row: 1;
  }
  :where(.clinker-app) .app-actions {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  :where(.clinker-app) .project-controls,
  :where(.clinker-app) .figure-menus,
  :where(.clinker-app) .utility-controls { gap: 4px; }
  :where(.clinker-app) .app-bar .app-logo {
    margin-right: 0;
    font-size: 1.2rem;
  }
  :where(.clinker-app) .app-bar .about-button {
    width: 24px;
    min-width: 24px;
  }
  :where(.clinker-app) .app-bar .app-button,
  :where(.clinker-app) .app-bar .menu > summary { padding-inline: 5px; }
  :where(.clinker-app) .order-menu .menu-current-value,
  :where(.clinker-app) .order-colon { display: none; }
  :where(.clinker-app) .app-bar .menu { position: static; }
  :where(.clinker-app) .app-bar .menu-popover {
    top: calc(100% + 4px);
    right: 8px;
    left: 8px;
    max-width: none;
  }
}

/* Plot workspace. */
:where(.clinker-app) .plot-stage {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
:where(.clinker-app) .plot-status {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 12px;
  margin: 0;
  padding: 5px 9px;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  background: var(--app-surface);
  box-shadow: 0 2px 8px rgba(23, 36, 54, .08);
  color: var(--app-muted);
  font-size: .8rem;
  pointer-events: none;
}
:where(.clinker-app) .plot-status[data-tone="error"] {
  border-color: var(--app-danger-border);
  background: var(--app-danger-surface);
  color: var(--app-danger);
}
:where(.clinker-app) .plot-stage > .cm-plot-selection-toolbar {
  z-index: 3;
  right: 12px;
  left: auto;
}
:where(.clinker-app) .plot-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
:where(.clinker-app) .plot-chart {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
:where(.clinker-app) .plot-editor {
  position: absolute;
  z-index: 3;
  right: 12px;
  bottom: 12px;
  left: 12px;
  height: min(36rem, 62vh);
  max-height: calc(100% - 3.5rem);
  box-shadow: 0 10px 35px rgba(23, 36, 54, .18);
}
@media (max-width: 760px) {
  :where(.clinker-app) .plot-editor {
    right: 8px;
    bottom: 8px;
    left: 8px;
    height: min(36rem, 68vh);
  }
}

/* Import controls. */
:where(.clinker-app) .import-options { display: flex; flex-wrap: wrap; gap: 14px; margin: 16px 0 14px; }
:where(.clinker-app) .import-options label { display: grid; flex: 1; gap: 6px; min-width: 180px; }
:where(.clinker-app) .import-file-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
:where(.clinker-app) .file-picker-name {
  flex: 1;
  color: var(--app-muted);
}

/* Tree input. */
:where(.clinker-app) .tree-history-note { margin-bottom: 0; }
:where(.clinker-app) .tree-options { margin-top: 14px; border-top: 1px solid var(--app-border); padding-top: 12px; }
:where(.clinker-app) .tree-options summary { cursor: pointer; color: var(--app-muted); }
:where(.clinker-app) .tree-root-metadata { margin-top: 16px; padding: 10px 12px; border: 1px solid var(--app-warning-border); border-radius: 6px; background: var(--app-warning-surface); }
:where(.clinker-app) .tree-root-metadata p { margin: 0 0 8px; }
:where(.clinker-app) .tree-matching { margin-top: 18px; }
:where(.clinker-app) .tree-matching[open] summary { margin-bottom: 12px; }
:where(.clinker-app) .tree-import-options { margin-top: 20px; }
:where(.clinker-app) .tree-root-option { display: flex; align-items: center; gap: 8px; }
:where(.clinker-app) .tree-import-note { color: var(--app-muted); font-size: .9rem; }
:where(.clinker-app) .tree-match-error,
:where(.clinker-app) .tree-import-status[data-tone="error"] { color: var(--app-danger); }
:where(.clinker-app) .tree-match-error { display: block; margin-top: 5px; overflow-wrap: anywhere; }
:where(.clinker-app) .tree-matching summary { cursor: pointer; font-weight: 600; }

:where(.clinker-app) .tree-matching-scroll { max-height: 15rem; overflow-y: auto; }
:where(.clinker-app) .tree-matching-table table { table-layout: fixed; font-size: .8rem; line-height: 1.2; }
:where(.clinker-app) .tree-matching-table th { font-size: .75rem; }
:where(.clinker-app) .tree-matching-table th:first-child,
:where(.clinker-app) .tree-matching-table td:first-child { width: 35%; }
:where(.clinker-app) .tree-matching-table td,
:where(.clinker-app) .tree-matching-table th { padding: var(--input-row-padding) 8px; border-bottom: 1px solid var(--app-border); overflow-wrap: anywhere; }
:where(.clinker-app) .tree-matching-table tbody tr { height: var(--input-row-height); }
:where(.clinker-app) .tree-matching-table tbody tr:last-child td { border-bottom: 0; }
:where(.clinker-app) .tree-inline-label { display: none; }
:where(.clinker-app) .run-tree-fields {
  margin: 16px 0 0;
  padding: 0;
}
:where(.clinker-app) .run-tree-fields .tree-inline-label { display: inline; flex-shrink: 0; font-weight: 600; }
:where(.clinker-app) .tree-inline-label span { font-weight: 400; color: var(--app-muted); }
:where(.clinker-app) .run-tree-fields .tree-file-picker { min-height: 36px; padding: 5px 8px; gap: 8px; font-size: .8rem; }
:where(.clinker-app) .run-tree-fields .tree-matching { margin: 0; border-top: 1px solid var(--app-border); }
:where(.clinker-app) .run-tree-fields .tree-matching summary { margin: 0; padding: 7px 8px; font-size: .8rem; }
:where(.clinker-app) .run-tree-fields .tree-matching > .tree-import-note { display: none; }
:where(.clinker-app) .run-tree-fields .tree-matching-table { border: 0; border-top: 1px solid var(--app-border); border-radius: 0; background: var(--app-surface); }
:where(.clinker-app) .run-tree-fields .tree-options { margin: 0; padding: 7px 8px; font-size: .8rem; }
:where(.clinker-app) .run-tree-fields .tree-import-options { margin: 12px 0 4px; }
:where(.clinker-app) .run-tree-fields .tree-import-status { margin: 0; padding: 7px 8px; font-size: .8rem; }
:where(.clinker-app) .run-tree-fields .tree-root-metadata { margin: 8px; font-size: .8rem; }
:where(.clinker-app) .run-tree-fields .tree-match-error:not(:empty) { padding: 0 8px; font-size: .8rem; }

/* Annotation import. */
:where(.clinker-app) .annotation-table-scroll .app-field { min-width: 0; }
:where(.clinker-app) .annotation-table-scroll .annotation-column-colour { width: 32px; min-width: 32px; min-height: 28px; height: 28px; padding: 2px; cursor: pointer; }
:where(.clinker-app) .annotation-table-scroll .annotation-column-colour:disabled { cursor: default; }
:where(.clinker-app) .annotation-column-name-input { max-width: 100%; }
:where(.clinker-app) .annotation-separate-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }
:where(.clinker-app) .annotation-column-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; max-width: 100%; min-width: 0; }
:where(.clinker-app) .annotation-selection-count { margin-right: 4px; color: var(--app-foreground); font-size: .85rem; font-weight: 600; white-space: nowrap; }
:where(.clinker-app) .annotation-column-actions > .app-field { width: auto; min-width: 145px; max-width: min(200px, 28vw); }
:where(.clinker-app) .annotation-panel-group-row > td { background: var(--app-subtle); font-weight: 600; }
:where(.clinker-app) .annotation-panel-name-content { display: flex; align-items: center; gap: 2px; min-width: 0; }
:where(.clinker-app) .annotation-panel-reorder { flex: 0 0 22px; width: 22px; min-width: 22px; min-height: 28px; height: 28px; padding: 0; opacity: 0; cursor: grab; font-size: 15px; letter-spacing: -3px; text-decoration: none; }
:where(.clinker-app) .annotation-panel-reorder:active { cursor: grabbing; }
:where(.clinker-app) .annotation-panel-reorder { opacity: .72; }
:where(.clinker-app) .annotation-panel-reorder:hover,
:where(.clinker-app) .annotation-panel-reorder:focus-visible { opacity: 1; }
:where(.clinker-app) .annotation-columns-table tbody tr.is-drop-before > td { box-shadow: inset 0 2px var(--app-primary); }
:where(.clinker-app) .annotation-columns-table tbody tr.is-drop-after > td { box-shadow: inset 0 -2px var(--app-primary); }
:where(.clinker-app) .app-button.annotation-group-toggle { flex: 0 0 14px; width: 14px; min-width: 14px; min-height: 22px; height: 22px; padding: 0; text-decoration: none; }
:where(.clinker-app) .annotation-group-toggle svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .12s ease; }
:where(.clinker-app) .annotation-group-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
:where(.clinker-app) .annotation-column-select-cell .annotation-group-toggle { margin-left: 1px; vertical-align: middle; }
:where(.clinker-app) .annotation-heatmap-group-title { flex: 1 1 180px; width: 180px; max-width: 100%; }
:where(.clinker-app) .annotation-group-scale-controls { display: flex; align-items: center; gap: 4px; min-width: 0; }
:where(.clinker-app) .annotation-group-palette,
:where(.clinker-app) .annotation-group-scale { width: 100%; min-width: 0; padding: 4px 22px 4px 7px; }
:where(.clinker-app) .annotation-group-scale-controls .annotation-group-scale { flex: 1 1 auto; width: auto; }
:where(.clinker-app) .annotation-group-scale-controls .annotation-remove-group { flex: 0 0 28px; width: 28px; min-width: 28px; min-height: 28px; height: 28px; }
:where(.clinker-app) .annotation-panel-type { color: var(--app-foreground); font-weight: 600; }
:where(.clinker-app) .annotation-heatmap-member > td { background: var(--app-subtle); }
:where(.clinker-app) .annotation-heatmap-member .annotation-group-member-name { padding-left: 25px; }
:where(.clinker-app) .annotation-heatmap-member .annotation-column-scale { white-space: nowrap; }
:where(.clinker-app) .annotation-columns-table tbody tr > td { border-bottom: 1px solid var(--app-border); }
:where(.clinker-app) .annotation-columns-table tbody tr:hover > td { background: var(--app-hover); }
:where(.clinker-app) .annotation-columns-table tbody tr.is-selected > td,
:where(.clinker-app) .annotation-columns-table tbody tr.is-selected:hover > td { background: var(--app-selection); }
:where(.clinker-app) .annotation-dialog-buttons { display: flex; align-items: center; gap: 10px; }
:where(.clinker-app) .annotation-separate-panels h3 { margin: 0; font-size: .9rem; }
:where(.clinker-app) .annotation-columns-table { table-layout: fixed; }
:where(.clinker-app) .annotation-columns-table .annotation-select-column { width: 72px; }
:where(.clinker-app) .annotation-columns-table .annotation-name-column { width: auto; }
:where(.clinker-app) .annotation-columns-table .annotation-output-column { width: 142px; }
:where(.clinker-app) .annotation-columns-table .annotation-palette-column { width: 132px; }
:where(.clinker-app) .annotation-columns-table .annotation-scale-column { width: 190px; }
:where(.clinker-app) .annotation-columns-table .annotation-column-kind { width: 100%; min-width: 0; padding: 3px 20px 3px 6px; }
:where(.clinker-app) .annotation-columns-table .annotation-column-select-cell { text-align: left; white-space: nowrap; }
:where(.clinker-app) .annotation-columns-table .annotation-column-select-cell > .annotation-column-select { margin: 0 2px 0 0; vertical-align: middle; }
:where(.clinker-app) .annotation-columns-table .annotation-column-name { overflow: hidden; }
:where(.clinker-app) .annotation-columns-table .annotation-column-scale { white-space: nowrap; font-variant-numeric: tabular-nums; }
:where(.clinker-app) .annotation-column-colour-cell { text-align: center; }
:where(.clinker-app) .annotation-dialog { max-height: min(88dvh, 900px); }
:where(.clinker-app) .annotation-match-summary { margin: 10px 0 0; }
:where(.clinker-app) .annotation-match-review,
:where(.clinker-app) .annotation-column-settings { margin-top: 12px; }
:where(.clinker-app) .annotation-match-review > p { margin: 0 0 10px; color: var(--app-muted); }
:where(.clinker-app) .annotation-column-settings h3 { margin: 0; font-size: .9rem; }
:where(.clinker-app) .annotation-preview { margin-top: 18px; }
:where(.clinker-app) .annotation-preview p { margin: 0; font-size: .9rem; color: var(--app-muted); }
:where(.clinker-app) .annotation-preview p[data-tone="error"] { color: var(--app-danger); }
:where(.clinker-app) .annotation-import-advanced { margin-top: 12px; }
:where(.clinker-app) .annotation-import-advanced summary { cursor: pointer; color: var(--app-muted); font-size: .9rem; }
:where(.clinker-app) .annotation-column-scale { font-size: .85rem; color: var(--app-muted); }
:where(.clinker-app) .annotation-column-note { margin: 0 0 10px; color: var(--app-muted); font-size: .9rem; }
:where(.clinker-app) .annotation-table-scroll { overflow: auto; }
:where(.clinker-app) .annotation-table-scroll th,
:where(.clinker-app) .annotation-table-scroll td { padding: 4px 7px; }
:where(.clinker-app) .annotation-table-scroll th { position: sticky; top: 0; font-size: .85rem; }
:where(.clinker-app) .annotation-match-key,
:where(.clinker-app) .annotation-column-name { overflow-wrap: anywhere; }

@media (max-width: 760px) {
  :where(.clinker-app) .annotation-columns-table .annotation-output-column { width: 132px; }
  :where(.clinker-app) .annotation-columns-table .annotation-scale-column { width: 165px; }
  :where(.clinker-app) .annotation-column-actions { flex-wrap: wrap; }
  :where(.clinker-app) .annotation-column-actions > .app-field { min-width: 0; }
}

/* Help. */
:where(.clinker-app) .help-dialog {
  --dialog-width: 840px;
  --dialog-header-padding: 22px 26px 18px;
  --dialog-body-padding: 22px 26px 26px;
}
:where(.clinker-app) .help-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 16px;
}
:where(.clinker-app) .help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px 32px;
}
:where(.clinker-app) .help-grid h3,
:where(.clinker-app) .help-about h3 {
  margin: 0 0 12px;
  color: var(--app-foreground);
  font-size: 1rem;
}
:where(.clinker-app) .help-grid p,
:where(.clinker-app) .help-grid dl { margin: 0; }
:where(.clinker-app) .help-grid section > p {
  margin-bottom: 12px;
  color: var(--app-muted);
}
:where(.clinker-app) .help-grid dl > div + div { margin-top: 12px; }
:where(.clinker-app) .help-grid dt {
  margin-bottom: 3px;
  font-weight: 600;
}
:where(.clinker-app) .help-grid dd {
  margin: 0;
  color: var(--app-muted);
  line-height: 1.45;
}
:where(.clinker-app) .help-grid kbd {
  display: inline-block;
  padding: 0 4px;
  border: 1px solid var(--app-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--app-subtle);
  font: inherit;
  font-size: .85em;
  white-space: nowrap;
}
:where(.clinker-app) .help-about {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--app-border);
}
:where(.clinker-app) .help-about p {
  margin: 0;
  color: var(--app-muted);
  line-height: 1.45;
}
:where(.clinker-app) .help-about p + p { margin-top: 12px; }
@media (max-width: 620px) {
  :where(.clinker-app) .help-grid { grid-template-columns: minmax(0, 1fr); }
  :where(.clinker-app) .help-dialog { --dialog-header-padding: 18px; --dialog-body-padding: 18px; }
}

/* Run setup. */
:where(.clinker-app) .record-coordinate .app-field {
  display: block;
  font-variant-numeric: tabular-nums;
}
:where(.clinker-app) .run-panel {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 24px;
  background: var(--app-run-backdrop);
  backdrop-filter: blur(3px);
}
:where(.clinker-app) .run-card {
  width: min(580px, 100%);
  padding: 24px;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface);
  box-shadow: 0 8px 28px rgba(23, 36, 54, .08);
  font-size: .85rem;
}
:where(.clinker-app) .run-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
:where(.clinker-app) .run-title {
  margin: 0;
  font-size: 1.3rem;
}
:where(.clinker-app) .settings-title {
  margin: 0;
  font-weight: 650;
  font-size: inherit;
}
:where(.clinker-app) .file-drop-zone {
  display: grid;
  min-width: 0;
  min-height: 116px;
  place-items: center;
  align-content: center;
  gap: 3px;
  padding: 15px;
  border: 1px dashed var(--app-border);
  border-radius: 9px;
  background: var(--app-subtle);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s ease, background-color .15s ease;
}
:where(.clinker-app) .file-drop-zone:hover,
:where(.clinker-app) .file-drop-zone.is-dragging {
  border-color: var(--app-focus-ring);
  background: var(--app-hover);
}
:where(.clinker-app) .file-drop-zone:focus-within {
  border-color: var(--app-focus-ring);
  outline: 2px solid var(--app-focus-ring);
  outline-offset: 1px;
}
:where(.clinker-app) .file-drop-zone:has(input:disabled) {
  color: var(--app-disabled-text);
  background: var(--app-subtle);
  cursor: default;
  opacity: .8;
}
:where(.clinker-app) .file-drop-icon {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid var(--app-border);
  border-radius: 50%;
  background: var(--app-surface);
  color: var(--app-accent);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}
:where(.clinker-app) .file-drop-title {
  font-size: .9rem;
  font-weight: 650;
}
:where(.clinker-app) .file-drop-action {
  color: var(--app-accent);
  font-size: .8rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

:where(.clinker-app) .file-input-status {
  display: grid;
  gap: 0;
  margin-top: 8px;
  padding: 0;
  font-size: .8rem;
}
:where(.clinker-app) .file-input-status-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  padding: 3px 8px;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-subtle);
}

:where(.clinker-app) .file-input-status ul {
  display: block;
  max-height: 22rem;
  margin: 0;
  overflow-y: auto;
  padding: 0 8px;
  list-style: none;
}
:where(.clinker-app) .file-input-status li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content max-content;
  align-items: center;
  column-gap: 10px;
  row-gap: 4px;
  min-width: 0;
  min-height: var(--input-row-height);
  padding: var(--input-row-padding) 0;
  border-top: 1px solid var(--app-border);
}
:where(.clinker-app) .file-input-status li:first-child { border-top: 0; }
:where(.clinker-app) .file-input-actions { display: flex; align-items: center; gap: 4px; }
:where(.clinker-app) .file-trim-toggle.is-trimmed::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 4px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
}
:where(.clinker-app) .file-drop-zone.has-files { display: flex; min-height: 0; padding: 10px; }
:where(.clinker-app) .file-drop-zone.has-files :is(.file-drop-icon, .file-drop-title) { display: none; }


:where(.clinker-app) .file-input-label {
  display: grid;
  min-width: 0;
  gap: 1px;
}
:where(.clinker-app) .file-input-name,
:where(.clinker-app) .file-input-description { line-height: 1.2; }
:where(.clinker-app) .file-input-description { font-size: .75rem; }
:where(.clinker-app) .file-input-state {
  color: var(--app-success);
  font-weight: 650;
  overflow-wrap: anywhere;
  text-align: right;
}
:where(.clinker-app) .file-input-status li[data-state="error"] .file-input-state { color: var(--app-danger); }
:where(.clinker-app) .file-input-reason {
  grid-column: 1 / -1;
  color: var(--app-danger);
  overflow-wrap: anywhere;
  padding-bottom: 4px;
}
:where(.clinker-app) .run-options {
  display: grid;
  gap: 6px;
  margin-top: 16px;
}
:where(.clinker-app) .setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--setting-control-width, 116px);
  min-width: 0;
  min-height: 34px;
  align-items: center;
  gap: 12px;
  padding: 2px 0;
}
:where(.clinker-app) .identity-setting {
  --setting-control-width: 90px;
  min-height: 38px;
  padding: 0;
}
:where(.clinker-app) .percentage-control {
  display: flex;
  align-items: center;
  gap: 6px;
}
:where(.clinker-app) .prefilter-option {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}
:where(.clinker-app) .setting-check {
  display: flex;
  min-width: 0;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
}
:where(.clinker-app) .setting-check:hover:not(:has(input:disabled)) { background: var(--app-subtle); }
:where(.clinker-app) .setting-check:has(input:disabled),
:where(.clinker-app) .setting-row:has(input:disabled) {
  color: var(--app-disabled-text);
  cursor: default;
}
:where(.clinker-app) .run-options .setting-check {
  min-height: 0;
  padding: 0;
}
:where(.clinker-app) .setting-help { margin: 0; }
:where(.clinker-app) .prefilter-option .setting-help { margin-left: 24px; }

:where(.clinker-app) .run-other-settings {
  margin-top: 15px;
  border-top: 1px solid var(--app-subtle);
}
:where(.clinker-app) .run-other-settings > summary {
  padding: 11px 0 2px;
  color: var(--app-muted);
  cursor: pointer;
  font-weight: 600;
}
:where(.clinker-app) .settings-sections {
  display: grid;
  gap: 20px;
  margin-top: 16px;
}
:where(.clinker-app) .settings-section {
  display: grid;
  gap: 7px;
  min-width: 0;
}
:where(.clinker-app) .file-trim-fields {
  grid-column: 1 / -1;
  min-width: 0;
  margin: 0;
  padding: 0 0 2px;
  border: 0;
}
:where(.clinker-app) .file-trim-fields:disabled { opacity: .65; }
:where(.clinker-app) .file-trim-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 2px 0;
}
:where(.clinker-app) .file-trim-range > .text-truncate { flex: 1 1 100px; }
:where(.clinker-app) .file-trim-coordinates {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  width: 290px;
  max-width: 100%;
}
:where(.clinker-app) .record-coordinate { display: block; }
:where(.clinker-app) .compact-file-row {
  font-size: .8rem;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(90px, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 2px 0;
}

:where(.clinker-app) .settings-fields { display: grid; gap: 8px; }
:where(.clinker-app) .prefilter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 4px 0 0 24px;
}
:where(.clinker-app) .prefilter-parameter { display: flex; align-items: center; gap: 8px; font-size: .8rem; }
:where(.clinker-app) .prefilter-parameter .app-field { width: 64px; flex: none; }
:where(.clinker-app) .compact-file-description {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  align-items: baseline;
  gap: 7px;
}
:where(.clinker-app) .compact-file-description small { color: var(--app-muted); }
:where(.clinker-app) .compact-file-description code { font-size: .75rem; }

:where(.clinker-app) .run-actions {
  font-weight: 600;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--app-subtle);
}
:where(.clinker-app) .run-card.is-busy .run-setup { display: none; }
:where(.clinker-app) .run-card.is-busy .run-feedback { margin-top: 0; }
:where(.clinker-app) .run-feedback {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--app-border);
  border-radius: 9px;
  background: var(--app-subtle);
  color: var(--app-muted);
}
:where(.clinker-app) .run-steps {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
:where(.clinker-app) .run-steps li {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 9px;
  min-height: 48px;
  padding-bottom: 8px;
}
:where(.clinker-app) .run-steps li:not(:last-child)::after {
  position: absolute;
  top: 24px;
  bottom: -2px;
  left: 11px;
  width: 2px;
  background: var(--app-border);
  content: "";
}
:where(.clinker-app) .step-marker {
  position: relative;
  z-index: 1;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--app-border);
  border-radius: 50%;
  background: var(--app-surface);
  color: var(--app-muted);
  font-size: .75rem;
  font-weight: 700;
}
:where(.clinker-app) .run-steps li[data-state="active"] .step-marker {
  border-color: var(--app-primary);
  background: var(--app-primary);
  color: var(--app-on-primary);
}
:where(.clinker-app) .run-steps li[data-state="complete"] .step-marker {
  border-color: var(--app-success-fill);
  background: var(--app-success-fill);
  color: var(--app-on-primary);
  font-size: 0;
}
:where(.clinker-app) .run-steps li[data-state="complete"] .step-marker::after {
  content: "✓";
  font-size: .8rem;
}
:where(.clinker-app) .run-steps li[data-state="error"] .step-marker {
  border-color: var(--app-danger-fill);
  background: var(--app-danger-fill);
  color: var(--app-on-primary);
}
:where(.clinker-app) .run-steps li[data-state="cancelled"] .step-marker {
  border-color: var(--app-disabled-text);
  background: var(--app-subtle);
  color: var(--app-muted);
}
:where(.clinker-app) .step-content {
  display: grid;
  min-width: 0;
  gap: 2px;
  padding-top: 2px;
}
:where(.clinker-app) .step-content strong { color: var(--app-foreground); }
:where(.clinker-app) .run-steps li[data-state="waiting"] .step-content { opacity: .55; }

:where(.clinker-app) .step-content progress {
  display: block;
  width: 100%;
  height: 5px;
  margin: 5px 0 2px;
  border: 0;
  accent-color: var(--app-primary);
}
:where(.clinker-app) .run-feedback p {
  margin: 0;
  padding: 9px 10px;
  border-radius: 7px;
}
:where(.clinker-app) .run-feedback p[data-tone="error"] {
  margin-top: 7px;
  background: var(--app-danger-surface);
  color: var(--app-danger);
}
@media (max-width: 760px) {
  :where(.clinker-app) .run-panel {
    align-items: start;
    padding: 14px;
  }
  :where(.clinker-app) .run-card { padding: 17px; }
  :where(.clinker-app) .compact-file-row { grid-template-columns: minmax(0, 1fr) auto; }
  :where(.clinker-app) .compact-file-row > .app-note { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  :where(.clinker-app) .run-actions .app-button.primary-action { grid-column: 1 / -1; }
  :where(.clinker-app) .run-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :where(.clinker-app) .file-input-status li { grid-template-columns: minmax(0, 1fr) auto; column-gap: 6px; }
  :where(.clinker-app) .file-input-label { grid-column: 1 / -1; }
  :where(.clinker-app) .file-input-state { text-align: left; }
  :where(.clinker-app) .file-input-actions { justify-self: end; }
  :where(.clinker-app) .file-input-state { max-width: 5rem; }
}
