/* CrackSight: light, plain desktop-tool styling. One accent color for primary actions. */
:root {
  --bg: #f2f2f0;
  --panel: #ffffff;
  --line: #d3d3cf;
  --line-strong: #b5b5b0;
  --text: #1c1c1a;
  --text-2: #55554f;
  --muted: #7a7a74;
  --accent: #8c1d40;
  --accent-hover: #74183a;
  --focus: #1b7fb5;
  --ok: #2e7d32;
  --warn: #9a5b00;
  --error: #b3261e;
  --viewer-bg: #2b2b2a;
  --input-bg: #ffffff;
  --button-bg: #fafaf8;
  --button-hover: #efefec;
  --hover: #f5f5f3;
  --current: #f7f3f4;
  --th-bg: #f7f7f5;
  --row-line: #ececea;
  --chart-main: #a8324f;   /* chart colors validated for color-vision deficiency on each surface */
  --chart-total: #1b7fb5;
  --chart-event: #c27a00;
  --chart-axis: #444444;
  --chart-grid: #ececea;
  --radius: 3px;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1b1a;
  --panel: #242423;
  --line: #3a3a38;
  --line-strong: #565652;
  --text: #e8e8e4;
  --text-2: #bdbdb6;
  --muted: #94948c;
  --accent: #8c1d40;
  --accent-hover: #a62650;
  --focus: #5aaadf;
  --ok: #6fbf73;
  --warn: #e0a84a;
  --error: #ef8a83;
  --viewer-bg: #151514;
  --input-bg: #1d1d1c;
  --button-bg: #2d2d2b;
  --button-hover: #383835;
  --hover: #2c2c2a;
  --current: #33262b;
  --th-bg: #2b2b29;
  --row-line: #333331;
  --chart-main: #d0577a;
  --chart-total: #3d9bd6;
  --chart-event: #c4841f;
  --chart-axis: #c8c8c0;
  --chart-grid: #343432;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--focus); }
h1 { font-size: 18px; margin: 0 0 12px; font-weight: 600; }
h2 { font-size: 14px; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 12px; margin: 14px 0 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
code { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.soon { color: var(--warn); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 14px; height: 40px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: .02em; }
.crumb-sep { color: var(--muted); }
.crumb { font-weight: 600; }
.spacer { flex: 1; }
.device { font-size: 12px; padding: 2px 8px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text-2); }
.device.warn { color: var(--warn); border-color: #e0c48f; background: #fff8ea; }
.user { color: var(--text-2); }

/* controls */
button, .button { font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 28px; padding: 3px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--button-bg); color: var(--text); cursor: pointer; text-decoration: none; }
button:hover, .button:hover { background: var(--button-hover); }
button:disabled { opacity: .5; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); }
button.link { border: 0; background: none; color: var(--focus); padding: 0; min-height: 0; }
button.danger, .danger { color: var(--error); }
button.active { background: var(--button-hover); border-color: var(--text-2); box-shadow: inset 0 0 0 1px var(--text-2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
input, select, textarea { font: inherit; padding: 4px 6px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--input-bg); color: var(--text); min-width: 0; }
input[type=number] { width: 90px; }
input[type=checkbox], input[type=radio] { margin: 0 6px 0 0; }
label { display: block; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.row > label { display: flex; align-items: center; gap: 6px; }
.stack > * + * { margin-top: 6px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 8px 0; padding: 6px 10px 10px; }
legend { padding: 0 4px; color: var(--text-2); }
details { margin: 8px 0; }
summary { cursor: pointer; color: var(--text-2); }

/* pages */
.page { max-width: 1100px; margin: 18px auto; padding: 0 16px; display: grid; gap: 16px; }
.narrow { max-width: 360px; margin: 60px auto; padding: 0 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.login label { margin: 10px 0; }
.login input { width: 100%; margin-top: 3px; }
.login button { margin-top: 8px; width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 14px; }
.form-grid label input, .form-grid label textarea { width: 100%; margin-top: 3px; }
.form-grid .wide { grid-column: 1 / -1; }
.msg { padding: 6px 10px; border-radius: var(--radius); border: 1px solid var(--line); margin: 8px 0; }
.msg.error { color: var(--error); border-color: #e9b4b0; background: #fdf3f2; }
.msg.warn { color: var(--warn); border-color: #e8cf9f; background: #fff9ee; }
.msg.ok { color: var(--ok); border-color: #b9d8bb; background: #f3faf3; }

table.grid { border-collapse: collapse; width: 100%; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
table.grid th { font-weight: 600; color: var(--text-2); background: var(--th-bg); }
table.kv { border-collapse: collapse; width: 100%; }
table.kv td { padding: 3px 0; border-bottom: 1px solid var(--row-line); vertical-align: top; }
table.kv td:last-child { text-align: right; font-variant-numeric: tabular-nums; padding-left: 8px; }
table.kv tr.sub td { color: var(--muted); font-size: 12px; }

/* workspace */
.ws-body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 200px minmax(0, 1fr) 330px; grid-template-rows: minmax(0, 1fr) auto; }
.steps { grid-row: 1 / 3; background: var(--panel); border-right: 1px solid var(--line); overflow: auto; padding: 10px 0; }
.steps ol { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 8px; padding: 7px 14px; cursor: pointer; color: var(--text-2); border-left: 3px solid transparent; }
.steps li::before { content: counter(step); width: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.steps li:hover { background: var(--hover); }
.steps li.current { color: var(--text); font-weight: 600; border-left-color: var(--accent); background: var(--current); }
.steps li.locked { color: var(--muted); opacity: .6; cursor: default; }
.steps .mark { order: 2; margin-left: auto; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid #b8b8b2; }
.steps li.done .mark { background: var(--ok); border-color: var(--ok); }
.steps li.attention .mark { background: #e9a23b; border-color: #c98a2e; }
.exp-meta { margin: 16px 14px 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; }
.exp-meta dt { color: var(--muted); }
.exp-meta dd { margin: 0 0 6px; }

.stage { position: relative; min-width: 0; min-height: 0; background: var(--viewer-bg); }
.viewer, .viewer canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.viewer canvas { display: block; cursor: crosshair; }
.viewer-hud { position: absolute; left: 8px; top: 8px; padding: 3px 8px; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: var(--radius); font-size: 12px; font-variant-numeric: tabular-nums; pointer-events: none; }
.viewer-hud:empty { display: none; }
.zoom-ctl { position: absolute; right: 8px; top: 8px; display: flex; gap: 2px; }
.zoom-ctl button { min-height: 24px; padding: 0 8px; background: rgba(255,255,255,.92); }
.dropzone { position: absolute; inset: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 2px dashed #8a8a85; border-radius: 4px; color: #e8e8e4; text-align: center; padding: 20px; }
.dropzone.over { border-color: #fff; background: rgba(255,255,255,.06); }
.dropzone .muted { color: #b5b5ae; }
.dropzone .button.secondary { background: transparent; color: #e8e8e4; border-color: #8a8a85; }
.charts { position: absolute; inset: 0; overflow: auto; background: var(--panel); padding: 10px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 6px 18px; align-content: start; }
.chart-box { min-width: 0; }
.chart-box h4 { margin: 6px 0 0; font-size: 12px; font-weight: 600; color: var(--text-2); }
.chart-box .hint { font-weight: 400; color: var(--muted); }

.side { grid-column: 3; grid-row: 1 / 3; overflow: auto; border-width: 0 0 0 1px; border-radius: 0; }
.side h2 { margin-top: 0; }
.side p { margin: 6px 0; }

.timeline { grid-column: 2; grid-row: 2; background: var(--panel); border-top: 1px solid var(--line); padding: 4px 10px 6px; }
.tl-controls { display: flex; gap: 4px; align-items: center; }
.tl-controls button { min-height: 24px; padding: 0 9px; }
.tl-controls select { padding: 2px 4px; }
.tl-label { margin-left: 8px; font-variant-numeric: tabular-nums; color: var(--text-2); }
#tl-canvas { width: 100%; height: 56px; display: block; cursor: pointer; margin-top: 4px; }

.progress { height: 8px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--th-bg); overflow: hidden; margin: 6px 0; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.toolbar { display: flex; flex-wrap: wrap; gap: 4px; }
.toolbar button { min-width: 0; padding: 3px 9px; }
.kbd { font-size: 11px; color: var(--muted); }
.legend-bar { height: 10px; border: 1px solid var(--line); background: linear-gradient(90deg, #440154, #3b528b, #21918c, #5ec962, #fde725); }
.legend-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.swatch { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 4px; }
.swatch.dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid #222; }
.checklist { list-style: none; padding: 0; margin: 6px 0; }
.checklist li { padding: 2px 0; }
.checklist li::before { content: "\2013"; margin-right: 6px; color: var(--muted); }
.checklist li.ok::before { content: "\2713"; color: var(--ok); }
.preview-img { width: 100%; border: 1px solid var(--line); display: block; margin: 6px 0; background: #222; }
.warnings { padding-left: 18px; margin: 6px 0; }
.warnings li { margin: 3px 0; color: var(--warn); }
.warnings li a { cursor: pointer; }

.statusbar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); max-width: 70vw; padding: 6px 14px; background: #2b2b2a; color: #fff; border-radius: var(--radius); font-size: 12px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 10; }
.statusbar.show { opacity: .95; }
.statusbar.error { background: var(--error); }

.uplot { font-family: inherit; }
.chart-box .u-legend { font-size: 11px; line-height: 1.3; margin-top: 2px; }
.chart-box .u-legend th { font-weight: 400; color: var(--text-2); }
.chart-box .u-legend .u-series > * { padding: 1px 3px; }
.chart-box .u-legend .u-marker { width: 12px; height: 8px; }
.chart-box .u-legend .u-value { color: var(--text); font-variant-numeric: tabular-nums; }
.chart-box .u-inline tr { margin-right: 10px; }

/* dark-theme message tints */
:root[data-theme="dark"] .msg.error { background: #3a2321; border-color: #6e3a36; }
:root[data-theme="dark"] .msg.warn { background: #362d1d; border-color: #6b5530; }
:root[data-theme="dark"] .msg.ok { background: #1f3020; border-color: #3e5f40; }
:root[data-theme="dark"] .device.warn { background: #362d1d; border-color: #6b5530; }
:root[data-theme="dark"] .viewer-hud, :root[data-theme="dark"] .zoom-ctl button { background: rgba(36,36,35,.92); color: var(--text); }

/* top bar icon buttons; the theme button shows the icon of the theme it switches to */
button.icon { min-height: 28px; width: 30px; padding: 0; border-color: var(--line); }
:root[data-theme="dark"] .i-moon, :root:not([data-theme="dark"]) .i-sun { display: none; }

/* labels with a tooltip */
.tip { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; cursor: help; }

/* Next-step row stays visible at the bottom of the step panel */
.next-row { position: sticky; bottom: -14px; margin: 14px -16px -14px; padding: 10px 16px 12px; background: var(--panel); border-top: 1px solid var(--line); display: flex; gap: 8px; }

/* edits list */
.edit-list { list-style: none; padding: 0; margin: 4px 0; }
.edit-list li { display: flex; align-items: center; gap: 6px; padding: 2px 0; border-bottom: 1px solid var(--row-line); }
.edit-list li .spacer { flex: 1; }

/* settings dialog */
.dialog { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0; background: var(--panel); color: var(--text); width: min(560px, 94vw); max-height: 86vh; }
.dialog::backdrop { background: rgba(0,0,0,.35); }
.dialog form { display: flex; flex-direction: column; max-height: 86vh; }
.dialog-head, .dialog-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; flex: 1; }
.dialog-foot { border-top: 1px solid var(--line); border-bottom: 0; }
.dialog-body { overflow: auto; padding: 6px 16px 10px; }
.dialog-body .row label { justify-content: space-between; width: 100%; }
.dialog-body .row label.check { justify-content: flex-start; }
