[hidden] { display: none !important; }
/*
 * Light theme in the style of GitHub / macOS apps: white surfaces, neutral
 * greys with no tint, hairline borders, and blue only for what is active.
 */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --subtle: #f6f8fa;      /* hover, inputs, quiet fills */
  --muted: #eef0f2;       /* pressed / selected fills */
  --line: #e1e4e8;        /* hairlines */
  --line-strong: #d0d7de; /* control borders */
  --text: #1f2328;
  --dim: #656d76;
  --faint: #8c959f;
  --accent: #0969da;
  --accent-hover: #0860ca;
  --stage: #f3f4f6;       /* behind the image: neutral, no blue */
  --shadow-sm: 0 1px 2px rgba(31, 35, 40, 0.06);
  --shadow: 0 8px 24px rgba(31, 35, 40, 0.12), 0 1px 3px rgba(31, 35, 40, 0.08);
  color-scheme: light;
}
* { box-sizing: border-box; }

/*
 * Thin overlay-style scrollbars, identical on WKWebView, WebView2 and
 * WebKitGTK: no track or arrows, only a slim rounded thumb. Uses the
 * ::-webkit-scrollbar family only (the standard scrollbar-width/color
 * properties would switch Chromium to its own look and override this).
 */
::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-thumb {
  background-color: rgba(31, 35, 40, 0.22);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 8px;
  min-height: 28px;
  min-width: 28px;
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(31, 35, 40, 0.4); }
::-webkit-scrollbar-thumb:active { background-color: rgba(31, 35, 40, 0.55); }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}
body { display: flex; flex-direction: column; }

/* Buttons are quiet by default: no fill until hovered. */
button {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px;
  padding: 0 9px;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
button:hover:not(:disabled) { background: var(--subtle); }
button:active:not(:disabled) { background: var(--muted); }
button:disabled { opacity: 0.35; cursor: default; }
button.on { background: var(--muted); color: var(--accent); }
button.on:hover:not(:disabled) { background: #e6e9ec; }
button.small svg { width: 14px; height: 14px; }
button.small { height: 24px; padding: 0 8px; font-size: 12px; border-color: var(--line-strong); background: var(--surface); box-shadow: var(--shadow-sm); }
button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

input[type="number"], select {
  height: 26px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 6px;
  font: inherit;
}
input[type="number"] { width: 92px; }
input[type="number"]:focus, select:focus { outline: 2px solid rgba(9, 105, 218, 0.3); outline-offset: 0; border-color: var(--accent); }
input[type="range"], input[type="checkbox"] { accent-color: var(--accent); }
input[type="color"] {
  width: 26px; height: 26px; padding: 3px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); cursor: pointer; vertical-align: middle;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }

/* ---------- title bar ---------- */

#toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.group { display: flex; align-items: center; gap: 4px; flex: none; }
#file-group { min-width: 0; flex: 0 1 auto; }
.spacer { flex: 1; }
/* Icon-only buttons at both ends of the title bar. */
#btn-open, #btn-settings { width: 30px; padding: 0; justify-content: center; color: var(--dim); }
#btn-open:hover, #btn-settings:hover { color: var(--text); }
#btn-open svg, #btn-settings svg { width: 18px; height: 18px; }
#btn-open.open, #btn-settings.open { background: var(--muted); color: var(--text); }
#btn-settings { position: relative; }
/* A new version: a quiet dot, cleared once the ⚙ menu has been opened. */
#update-dot, #dropmenu .mi-dot { width: 7px; height: 7px; border-radius: 50%; background: #e5534b; pointer-events: none; }
#update-dot { position: absolute; top: 4px; right: 4px; box-shadow: 0 0 0 1.5px var(--surface); }
#update-dot[hidden] { display: none; }
#dropmenu .mi-dot { display: inline-block; margin-left: 6px; vertical-align: 2px; }
#btn-prev, #btn-next { width: 26px; padding: 0; justify-content: center; font-size: 11px; color: var(--dim); }
#file-pos { color: var(--dim); min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }
#series { max-width: 220px; margin-left: 4px; }

/* The tool buttons scroll sideways when the window is too narrow. */
#quickbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 0;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 4px;
}
#quickbar::-webkit-scrollbar { display: none; }
#quickbar > * { flex: none; }
#quickbar .seg { display: flex; gap: 2px; padding: 2px; background: var(--subtle); border-radius: 8px; }
#quickbar .seg button { height: 26px; width: 30px; }
#quickbar #btn-axis { width: auto; min-width: 34px; gap: 1px; padding: 0 3px 0 7px; font-size: 12px; font-weight: 600; }
#quickbar #btn-axis svg { width: 12px; height: 12px; stroke-width: 2; }
#quickbar #btn-axis.open { background: var(--muted); color: var(--text); }
/* Tool with a shape menu: the icon picks the tool, the narrow arrow beside it opens the menu. */
#quickbar .seg .split { display: flex; border-radius: 6px; }
#quickbar .seg .split button { border-radius: 6px 0 0 6px; }
#quickbar .seg .split .caret { width: 14px; border-radius: 0 6px 6px 0; }
#quickbar .seg .split .caret svg { width: 12px; height: 12px; stroke-width: 2; }
#quickbar .seg .split.on { background: var(--surface); box-shadow: 0 1px 3px rgba(31, 35, 40, 0.12), 0 0 0 1px rgba(31, 35, 40, 0.06); }
#quickbar .seg .split.on button { background: transparent; box-shadow: none; color: var(--accent); }
#quickbar .seg .split.on button:hover { background: var(--subtle); }
#quickbar .seg .split.open .caret { background: var(--muted); color: var(--text); }
#quickbar .seg button:hover:not(.on) { background: var(--muted); color: var(--text); }
#quickbar .seg button.on { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(31, 35, 40, 0.12), 0 0 0 1px rgba(31, 35, 40, 0.06); }
#quickbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
/* Icon-only buttons; the label is in the tooltip. */
#quickbar button { width: 30px; padding: 0; justify-content: center; color: var(--dim); }
#quickbar button:hover:not(:disabled) { color: var(--text); }
#quickbar button.on { color: var(--accent); }
#quickbar button svg { width: 17px; height: 17px; }
.scroll-btn { flex: none; width: 24px; padding: 0; justify-content: center; font-size: 18px; color: var(--dim); }
#view-group { padding-left: 8px; border-left: 1px solid var(--line); }
.zoom { display: flex; align-items: center; gap: 0; }
.zoom button { padding: 0; justify-content: center; }
#btn-zoomout, #btn-zoomin { width: 26px; font-size: 16px; }
#btn-zoom { width: 52px; font-size: 12px; font-variant-numeric: tabular-nums; }

#channels { display: flex; gap: 4px; flex-wrap: nowrap; margin-left: 6px; }
.chan {
  display: flex; align-items: center; gap: 5px;
  height: 24px;
  padding: 0 9px 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  cursor: pointer;
  background: var(--surface);
}
.chan input { margin: 0; }
.chan.off .nm { opacity: 0.45; text-decoration: line-through; }
.chan.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.chan .sw { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(31, 35, 40, 0.25) inset; flex: none; }

/* ---------- image area ---------- */

#body { flex: 1; min-height: 0; display: flex; }
#stage { position: relative; flex: 1; min-width: 0; overflow: hidden; background: var(--stage); }
#view { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#view.drag { cursor: grabbing; }
#view.cross { cursor: crosshair; }
#view.text { cursor: text; }
/* In-place editor of a text annotation, over where the text will be drawn. */
#text-edit {
  position: absolute; z-index: 4;
  min-width: 40px; padding: 2px 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px dashed var(--accent); border-radius: 4px;
  outline: none;
  caret-color: currentColor;
  text-shadow: 0 0 2px #000, 0 0 2px #000;
}
#empty {
  position: absolute; inset: 0;
  display: flex; justify-content: center; align-items: flex-start;
  overflow: auto;
  color: var(--dim); pointer-events: none; text-align: left;
  padding: 22px 20px 16px;
}
/* The tools panel floats over the stage. Keep the home in the space it leaves. */
#stage:has(#tools:not([hidden])) #empty { left: calc(var(--tools-w, 288px) + 22px); }
#home {
  pointer-events: auto;
  width: min(860px, 100%);
  display: flex; flex-direction: column; gap: 14px;
}
#empty .big { margin: 2px 0 0; font-size: 18px; line-height: 1.45; color: var(--text); }
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 14px;
  align-items: start;
}
.home-card {
  min-width: 0;
  padding: 4px 14px 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
#recent-list { display: flex; flex-direction: column; }
.recent-empty { padding: 8px 0 4px; font-size: 12px; border-top: 1px solid var(--line); }
.recent-row {
  width: 100%; height: auto; min-height: 40px;
  padding: 6px 2px;
  border: none; border-radius: 0; border-top: 1px solid var(--line);
  background: transparent; box-shadow: none;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  text-align: left; white-space: normal;
}
.recent-row:hover:not(:disabled) { background: var(--subtle); }
.recent-row b, .recent-row span {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recent-row b { font-weight: 600; font-size: 12px; }
.recent-row span { color: var(--dim); font-size: 11px; }
#empty .hint { margin: 0; line-height: 1.5; }
.fmt-head { margin: 10px 0 4px; font-size: 12px; font-weight: 600; color: var(--dim); }
.fmt-head .dim { font-weight: 400; margin-left: 6px; color: var(--faint); }
.fmt-core { display: flex; flex-direction: column; }
.fmt-item, .fmt-plugin { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); min-width: 0; }
.fmt-item b, .fmt-plugin b { flex: none; font-weight: 600; font-size: 12px; }
.fmt-item span, .fmt-plugin .ext { min-width: 0; color: var(--dim); font-size: 12px; overflow-wrap: anywhere; }
.fmt-plugin { align-items: center; }
.fmt-plugin .ext { flex: 1; }
.fmt-plugin button { flex: none; }
.fmt-plugin .done { flex: none; font-size: 12px; color: var(--faint); }
#fmt-plugins > .dim { padding: 6px 0; font-size: 12px; border-top: 1px solid var(--line); }
#loading, #size-out {
  position: absolute; top: 10px;
  padding: 4px 12px; border-radius: 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none;
}
#loading { right: 12px; color: var(--dim); }
#loading.progress {
  color: var(--text);
  background: linear-gradient(to right, color-mix(in srgb, var(--accent) 28%, var(--surface)) var(--p, 0%), var(--surface) var(--p, 0%));
}
#size-out { left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; }
/* Centre over the part of the image the tools panel leaves free. */
#stage:has(#tools:not([hidden])) #size-out { left: calc(50% + (var(--tools-w, 288px) + 10px) / 2); }
#size-out button, #size-out input { pointer-events: auto; }
#size-out button { height: 22px; padding: 0 8px; font-size: 12px; border-color: var(--line-strong); }
#ann-z { color: var(--accent); }
#ann-z-edit { display: inline-flex; align-items: center; gap: 4px; }
#ann-z-edit input { width: 58px; height: 22px; }
#drop-hint {
  position: absolute; inset: 10px; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--accent); border-radius: 12px;
  background: rgba(9, 105, 218, 0.08);
  pointer-events: none;
}
#drop-hint div { padding: 8px 16px; border-radius: 8px; background: var(--surface); color: var(--accent); font-size: 15px; font-weight: 600; box-shadow: var(--shadow); }

/* Side panel with contrast, annotations, IMOD and scale bar settings. */
#tools {
  position: absolute; top: 10px; left: 10px; bottom: 10px;
  width: var(--tools-w, 288px);
  overflow-y: auto;
  padding: 2px 14px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
#tools section { padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
#tools section:last-child { border-bottom: none; }
#tools h3 { margin: 2px 0 8px; font-size: 12px; font-weight: 600; color: var(--dim); }
#tools .row { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
#tools .row label { display: inline-flex; align-items: center; gap: 6px; }
#tools .slider { display: grid; grid-template-columns: 72px 1fr 36px; align-items: center; gap: 6px; margin: 4px 0; }
#tools .slider input { width: 100%; }
#hist { width: 100%; height: 64px; background: var(--subtle); border: 1px solid var(--line); border-radius: 6px; cursor: ew-resize; display: block; }
#measure-out { min-height: 18px; font-variant-numeric: tabular-nums; }
#tools .dim { font-size: 12px; }
#tools.only-contrast { bottom: auto; }
#tools:not(.only-info) #sec-meta, #tools.only-info section:not(#sec-meta) { display: none; }
#tools.only-info section { border-bottom: none; }
#meta-filter { flex: 1; min-width: 0; }
#meta-list details { margin: 8px 0; }
#meta-list summary { cursor: pointer; font-weight: 600; font-size: 12px; padding: 3px 0; }
#meta-list summary .dim { font-weight: 400; margin-left: 4px; }
#meta-list table { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
#meta-list td { padding: 3px 4px; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; user-select: text; }
#meta-list td:first-child { color: var(--dim); width: 46%; }
#meta-list td:last-child { font-variant-numeric: tabular-nums; }
#meta-list tr:hover td { background: var(--subtle); }
#meta-list .none { padding: 6px 0; }
#tools.only-contrast section { border-bottom: none; }
#tools.only-contrast section:not(#sec-contrast) { display: none; }
#ann-file { margin-top: 4px; word-break: break-all; }

#mod-objects { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; max-height: 160px; overflow-y: auto; }
#mod-objects label { display: flex; align-items: center; gap: 6px; font-size: 12px; }
#mod-objects .sw { width: 11px; height: 11px; border-radius: 2px; flex: none; }

/* ---------- thumbnails ---------- */

#sidebar {
  flex: 0 0 var(--sidebar-w, 196px);
  background: var(--surface);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  overflow-x: hidden;
}
#sidebar.collapsed { display: none; }

/* Drag handles on the inner edge of both side panels. */
.resizer { position: relative; flex: none; width: 0; z-index: 5; }
.resizer::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -4px; width: 8px;
  cursor: col-resize;
}
.resizer:hover::after, .resizer.active::after { background: linear-gradient(90deg, transparent 3px, var(--accent) 3px, var(--accent) 5px, transparent 5px); }
#tools-resizer { position: absolute; top: 22px; bottom: 22px; left: calc(10px + var(--tools-w, 288px)); }
#tools[hidden] ~ #tools-resizer, #tools.only-contrast ~ #tools-resizer { display: none; }
/* Fold buttons inside the side panels; the matching show buttons sit in the title bar while a panel is folded. */
.panel-close { width: 26px; height: 24px; padding: 0; justify-content: center; color: var(--dim); flex: none; }
.panel-close:hover:not(:disabled) { color: var(--text); }
.panel-close svg { width: 16px; height: 16px; }
/* While a panel is folded, its show button sits on the same row the fold button was on, at the window edge. */
.panel-open {
  position: absolute; z-index: 7;
  width: 30px; height: 26px; padding: 0; justify-content: center;
  color: var(--dim); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.panel-open:hover:not(:disabled) { background: var(--subtle); color: var(--text); }
.panel-open svg { width: 16px; height: 16px; }
/* Left edge: the tools panel and the parts of it that open on their own (brightness/contrast, image info). */
.edge-rail { position: absolute; z-index: 7; top: 18px; left: 0; display: flex; flex-direction: column; gap: 4px; }
.edge-rail .panel-open { position: static; border-left: none; border-radius: 0 6px 6px 0; }
.edge-rail .panel-open:disabled { opacity: 1; color: var(--line-strong); }
#btn-show-sidebar { top: 7px; right: 0; border-right: none; border-radius: 6px 0 0 6px; }
/* Keep the floating panels at the top right clear of it. */
#stage:has(#btn-show-sidebar:not([hidden])) #fft-panel,
#stage:has(#btn-show-sidebar:not([hidden])) #vol-panel { right: 40px; }
#tools-close { float: right; position: sticky; top: 8px; z-index: 1; margin: 7px -6px 0 4px; background: var(--surface); }
#side-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; background: var(--surface); border-bottom: 1px solid var(--line);
}
#folder-name { flex: 1; min-width: 0; font-size: 12px; font-weight: 600; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#side-head button.small { padding: 0 6px; }
#side-head .panel-close { margin-right: -4px; }
#save-dir { flex: 1; min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
#strip { display: flex; flex-direction: column; gap: 2px; padding: 4px 8px 8px; }
.strip-head {
  width: 100%; height: 26px; padding: 0 4px; gap: 4px;
  background: none; border: none; box-shadow: none;
  color: var(--dim); font-size: 12px; font-weight: 600;
}
.strip-head:hover:not(:disabled) { background: var(--subtle); color: var(--text); }
.strip-head svg { width: 14px; height: 14px; flex: none; transition: transform 0.12s; transform: rotate(90deg); }
.strip-group.folded .strip-head svg { transform: none; }
.strip-head .gn { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip-head .gc { color: var(--faint); font-weight: 400; }
.strip-body { display: flex; flex-direction: column; gap: 2px; }
.strip-group.folded .strip-body { display: none; }
.thumb {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 6px 6px;
  border-radius: 8px;
  cursor: pointer;
}
.thumb:hover { background: var(--subtle); }
.thumb .box { width: 100%; aspect-ratio: 164 / 116; display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: 12px; }
/* Only the picture gets a frame, so there are no bars beside it. */
.thumb canvas {
  max-width: 100%; max-height: 100%;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(31, 35, 40, 0.1), var(--shadow-sm);
}
.thumb.cur { background: var(--muted); }
.thumb.cur canvas { box-shadow: 0 0 0 2px var(--accent); }
.thumb .nm { width: 100%; margin-top: 4px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.thumb.cur .nm { color: var(--accent); font-weight: 600; }
.thumb .meta { font-size: 11px; color: var(--faint); }
.thumb.stack canvas { box-shadow: 4px -4px 0 -1px var(--line-strong), 8px -8px 0 -2px var(--line); }
.thumb.stack.cur canvas { box-shadow: 0 0 0 2px var(--accent), 5px -5px 0 0 var(--line-strong); }
.thumb.stack .meta { color: var(--accent); }

/* ---------- bottom bars ---------- */

#zbar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
#zbar button { width: 28px; padding: 0; justify-content: center; border-color: var(--line-strong); }
#xyz-axes { display: flex; align-items: center; gap: 8px; flex: 2; min-width: 0; }
#xyz-axes input { flex: 1; min-width: 48px; }
#xyz-xl, #xyz-yl { min-width: 52px; font-variant-numeric: tabular-nums; color: var(--dim); }
#zbar input[type="range"] { flex: 1; }
/* Z slider with the Z ranges that carry annotations marked above the track. */
#zwrap { position: relative; flex: 1; display: flex; align-items: center; }
#zwrap input { flex: 1; width: 100%; margin: 0; }
#zmarks { position: absolute; left: 8px; right: 8px; top: -5px; height: 6px; pointer-events: none; }
#zmarks i { position: absolute; top: 0; height: 6px; min-width: 6px; margin-left: -3px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3); }
#tgroup { display: flex; align-items: center; gap: 8px; flex: 0 0 30%; }
#zlabel, #tlabel { min-width: 64px; font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }

#status {
  display: flex; gap: 18px;
  padding: 3px 12px 4px;
  color: var(--dim);
  background: var(--subtle);
  border-top: 1px solid var(--line);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}

#toast {
  position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%);
  max-width: 70vw;
  padding: 8px 14px; border-radius: 8px;
  background: rgba(31, 35, 40, 0.92); color: #fff;
  box-shadow: var(--shadow);
  word-break: break-all;
}

/* ---------- plugins and updates ---------- */


#plugin-buttons:empty { display: none; }
#plugin-buttons select { height: 28px; }

.dialog {
  position: fixed; top: 52px; right: 12px; z-index: 10;
  width: 340px; max-height: calc(100vh - 80px); overflow-y: auto;
  padding: 4px 14px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.dialog .dlg-head { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.dialog h3 { margin: 6px 0; font-size: 13px; }
.dialog .row { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.plugin-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.plugin-row input { margin-top: 3px; }
.plugin-row .pl-text { flex: 1; min-width: 0; }
.plugin-row .pl-actions { display: flex; flex-direction: column; align-items: stretch; gap: 6px; flex: none; }
.plugin-row .pl-actions button { justify-content: center; }
.pl-hint { padding: 8px 0; font-size: 12px; border-bottom: 1px solid var(--line); }
.plugin-row .dim { font-size: 12px; }
.pl-name { font-weight: 600; }
.pl-err { color: #cf222e; font-size: 12px; }
#market-confirm { margin: 8px 0 4px; padding: 10px 12px 2px; border: 1px solid var(--accent); border-radius: 10px; }
#market-confirm .dim { font-size: 12px; margin-top: 4px; }
#market-confirm .dim:empty { display: none; }
#market-confirm #mc-msg.pl-err { color: #cf222e; }
.market-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.market-row .pl-text { flex: 1; min-width: 0; }
.market-row .dim { font-size: 12px; }
.market-row button { flex: none; }
#market-list > .dim { padding: 8px 0; font-size: 12px; }
#market-search { width: 100%; height: 28px; padding: 0 8px; margin: 4px 0; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; }
#market-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }

/* ---------- drop-down menus ---------- */

#dropmenu {
  position: fixed; z-index: 30;
  display: flex; flex-direction: column; gap: 1px;
  min-width: 150px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
#dropmenu button { width: 100%; height: 30px; gap: 8px; padding: 0 8px; color: var(--text); }
#dropmenu button svg { width: 16px; height: 16px; color: var(--dim); }
#dropmenu button.on { background: var(--muted); color: var(--accent); }
#dropmenu button.on svg { color: var(--accent); }
#dropmenu .mi-label { font-weight: 500; }
#dropmenu .mi-hint { color: var(--dim); font-size: 12px; }
#dropmenu kbd {
  margin-left: auto; padding-left: 16px;
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--faint);
}

#fft-panel {
  position: absolute; top: 10px; right: 10px;
  width: 300px;
  padding: 8px 10px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.fft-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.fft-head b { flex: 1; }
#fft-info { font-size: 11px; }
#fft-img { width: 100%; aspect-ratio: 1; display: block; background: #000; border-radius: 6px; image-rendering: pixelated; cursor: crosshair; }
#fft-prof { width: 100%; height: 90px; display: block; margin-top: 8px; background: var(--subtle); border: 1px solid var(--line); border-radius: 6px; cursor: crosshair; }
#fft-read { min-height: 18px; margin-top: 6px; font-size: 12px; font-variant-numeric: tabular-nums; }

#spec-panel {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  height: 230px;
  display: flex; flex-direction: column;
  padding: 8px 10px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.spec-head { display: flex; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 4px; }
.spec-head #spec-read { flex: 1; font-size: 12px; font-variant-numeric: tabular-nums; }
.spec-head #spec-src { font-size: 12px; }
#spec-plot { flex: 1; width: 100%; min-height: 0; display: block; cursor: crosshair; }

#help-keys { width: 100%; border-collapse: collapse; font-size: 12px; margin: 4px 0 6px; }
#help-keys td { padding: 4px 4px; border-top: 1px solid var(--line); vertical-align: top; }
#help-keys td:first-child { width: 42%; color: var(--dim); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; white-space: nowrap; }
#help-version { flex: 1; font-size: 12px; }

/* Touch screens (Android): hints for fingers instead of mouse and keys. */
.touch-only { display: none; }
@media (pointer: coarse) {
  .touch-only { display: block; }
  .desk-only { display: none; }
}

/* Long-press menu for an annotation on touch screens. */
#ann-menu {
  position: absolute; z-index: 30; transform: translate(-50%, -100%);
  padding: 4px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 10px; box-shadow: var(--shadow);
}
#ann-menu button { height: 40px; padding: 0 20px; font-size: 15px; color: #cf222e; border: 0; }

/* Narrow windows (a tablet held upright): the tool buttons get a row of
   their own instead of being squeezed between the file and view groups. */
@media (max-width: 860px) {
  #toolbar { flex-wrap: wrap; height: auto; padding: 4px 10px; row-gap: 4px; }
  #file-group { flex: 1 1 auto; }
  #scroll-left, #quickbar, #scroll-right { order: 2; }
  #quickbar { flex: 1 1 calc(100% - 64px); height: 36px; }
}

/* ---------- about ---------- */

.about-app { display: flex; gap: 12px; align-items: center; padding: 6px 0 10px; border-bottom: 1px solid var(--line); }
.about-title { font-size: 16px; font-weight: 600; }
.about-sec { padding: 10px 0; border-bottom: 1px solid var(--line); }
.about-sec .pl-name { font-size: 14px; margin-top: 2px; }
.about-links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; }
.about-links a { color: var(--accent); text-decoration: none; }
.about-links a:hover { text-decoration: underline; }
.about-cite { margin-top: 6px; padding: 8px; font-size: 12px; background: var(--subtle); border-radius: 6px; user-select: text; -webkit-user-select: text; overflow-wrap: anywhere; }
.about-foot { padding-top: 8px; font-size: 12px; }

#update-notes { margin: 4px 0 0; max-height: 220px; overflow: auto; white-space: pre-wrap; font: inherit; font-size: 12px; }
