/* PixelKit Tools - batch 1 (001-020).
   Design language follows the existing fitpixelkit.com main site:
   primary #2b53e5, surface #ffffff, page #f4f6fa, ink #18243b, muted #67758a. */

:root {
  --primary: #2b53e5;
  --primary-dark: #1f3fb0;
  --primary-soft: #eef2ff;
  --ink: #18243b;
  --muted: #67758a;
  --line: #e3e7ef;
  --page: #f4f6fa;
  --surface: #ffffff;
  --ok: #0f7b4f;
  --ok-soft: #e7f6ee;
  --warn: #8a5a00;
  --warn-soft: #fdf3e0;
  --bad: #b3261e;
  --bad-soft: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(24, 36, 59, .06), 0 8px 24px rgba(24, 36, 59, .06);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.65 Inter, "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------- Mode diagram (002-M04) ---------------- */

.mode-diagram {
  --dg-bg: #ffffff;
  width: 100%;
  max-width: 260px;
  margin: 4px 0 12px;
}

.mode-diagram .dg-frame {
  position: relative;
  width: 100%;
  height: 132px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--dg-bg);
}

.mode-diagram .dg-content {
  position: absolute;
  background: var(--primary-soft);
  border: 2px solid var(--primary);
  border-radius: 4px;
}

/* fit: the canvas follows the picture, so the drawing touches two sides only */
.mode-diagram[data-mode="fit"] .dg-content { left: 0; top: 25%; width: 100%; height: 50%; }

/* crop: the picture is larger than the canvas and gets clipped */
.mode-diagram[data-mode="crop"] .dg-content { left: -20%; top: -20%; width: 140%; height: 140%; }

/* pad: the whole picture stays inside on a filled background */
.mode-diagram[data-mode="pad"] .dg-content { left: 20%; top: 25%; width: 60%; height: 50%; }

.mini-field { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
input.mini { width: 56px; padding: 3px 5px; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; }
.unmet { margin-top: 10px; }
figure.preview { margin: 12px 0 0; }
img.preview { max-width: 140px; max-height: 140px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* ---------------- Header ---------------- */

header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 5.5%;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 92px;
  flex-wrap: wrap;
}

.brand {
  font-size: 24px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mark {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  color: #fff;
  background: var(--primary);
  border-radius: 9px;
  font-size: 26px;
}

.header-note { color: var(--muted); font-size: 14px; }
.header-spacer { flex: 1 1 auto; }

.lang-switch { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.lang-switch select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

main {
  max-width: 1280px;
  margin: auto;
  padding: 40px 36px 80px;
}

/* ---------------- Home ---------------- */

.intro { margin-bottom: 32px; }

.eyebrow {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--muted);
  font-weight: 700;
  margin: 0 0 10px;
}

h1 {
  font-size: 40px;
  line-height: 1.25;
  letter-spacing: -1px;
  margin: 0 0 12px;
}

h1 span { color: var(--primary); }
.lede { color: var(--muted); margin: 0; max-width: 68ch; }

.phase-nav { margin: 28px 0 18px; display: flex; gap: 8px; flex-wrap: wrap; }

.phase-nav button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
}

.phase-nav button[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
}

.tool-card h2 { font-size: 17px; margin: 0; }
.tool-card p { margin: 0; color: var(--muted); font-size: 14px; }
.tool-card .meta { font-size: 12px; color: var(--muted); letter-spacing: .4px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge.pending { background: var(--warn-soft); color: var(--warn); }

/* ---------------- Tool workspace ---------------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  main { padding: 28px 16px 64px; }
  header { padding: 0 16px; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel-heading { margin-bottom: 14px; }
.panel-heading h2 { font-size: 15px; margin: 0; letter-spacing: .3px; }
.panel-heading h2 span { color: var(--primary); }
.panel-heading p { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

.drop {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 168px;
  padding: 20px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  cursor: pointer;
  text-align: center;
}

.drop:hover, .drop.dragover { border-color: var(--primary); background: var(--primary-soft); }
.drop .upload-icon { font-size: 28px; color: var(--primary); }
.drop small { color: var(--muted); font-size: 12px; }
.drop input { display: none; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field input[type="number"], .field input[type="text"], .field select, .field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.field textarea { min-height: 120px; resize: vertical; }

.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline > label { font-size: 13px; }

.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 10px; }

button.primary {
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
button.primary:hover { background: var(--primary-dark); }
button.primary:disabled { background: #b9c2dc; cursor: not-allowed; }

button.ghost {
  padding: 9px 14px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  cursor: pointer;
  color: var(--ink);
}

button.text-button {
  border: 0; background: none; padding: 0;
  color: var(--primary); cursor: pointer; font-weight: 600;
}

.status {
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
  min-height: 1.6em;
}
.status.error { color: var(--bad); }
.status.ok { color: var(--ok); }

.download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 11px 16px;
  border-radius: 10px;
  background: var(--ok);
  color: #fff;
  font-weight: 700;
}

/* ---------------- Results ---------------- */

.results { margin-top: 24px; }

.result-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--surface);
  margin-bottom: 12px;
}

.result-item header {
  min-height: 0;
  border: 0;
  padding: 0;
  background: none;
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
}

.result-item h3 { font-size: 15px; margin: 0; word-break: break-all; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.pill.pass { background: var(--ok-soft); color: var(--ok); }
.pill.fail { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

.rule-list { list-style: none; margin: 12px 0 0; padding: 0; }
.rule-list li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.rule-list li:first-child { border-top: 0; }
.rule-list .name { font-weight: 600; min-width: 9em; }
.rule-list .actual { color: var(--muted); }
.rule-list .why { color: var(--muted); font-size: 12px; }

.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.notes {
  margin-top: 24px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  color: var(--muted);
}

.notes ul { margin: 8px 0 0; padding-left: 18px; }

.progress {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}
.progress > div {
  height: 100%;
  background: var(--primary);
  width: 0;
  transition: width .18s ease;
}

.queue-list { list-style: none; margin: 14px 0 0; padding: 0; }
.queue-list li {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap; /* narrow viewports must stack, not overflow */
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.queue-list li:first-child { border-top: 0; }
.queue-list .grow { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Per-file extras (inspection reports, plans, warnings) always occupy their own
   full-width row below the file name, whatever the viewport width. */
.file-extras {
  flex: 1 1 100%;
  display: grid;
  gap: 6px;
  justify-items: start;
  min-width: 0;
}
.file-extras > * { max-width: 100%; min-width: 0; }

/* ---------------- Field reports (M15) ---------------- */

.field-group { margin: 10px 0 0; }
.field-group > .group-heading {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.tag-list { list-style: none; margin: 6px 0 0; padding: 0; }
.tag-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
  padding: 5px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.tag-list li:first-child { border-top: 0; }
.tag-list .tag { font-weight: 600; }
.tag-list .value,
.tag-list .tag { min-width: 0; overflow-wrap: anywhere; }
.tag-list .value { color: var(--muted); }

.plan, .coverage {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  max-width: 100%;
}
.plan summary, .coverage summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.plan > ul, .coverage > p { margin: 8px 0 0; }
.coverage p { overflow-wrap: anywhere; }

.small { font-size: 12px; }

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.preview-grid figure { margin: 0; }
.preview-grid img {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.preview-grid figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }

table.report {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 12px;
}
table.report th, table.report td {
  border: 1px solid var(--line);
  padding: 7px 9px;
  text-align: left;
}
table.report th { background: #fafbfe; }

/* Keep spacing and wide reports compatible with a strict style-src self policy. */
.run-row { margin-top: 14px; }
.spaced-row { margin-top: 12px; }
.file-extras, .result-item { overflow-x: auto; }
.preview-grid figcaption { overflow-wrap: anywhere; }
.analytics-preferences{margin:36px 0 20px;padding:24px;border:1px solid #d7e1f3;border-radius:16px;background:#f6f9ff;display:flex;gap:24px;align-items:center;justify-content:space-between}
.analytics-preferences h2{margin:0 0 8px;font-size:20px}
.analytics-preferences p{margin:6px 0;max-width:690px;color:#516174}
.analytics-actions{display:flex;gap:10px;flex-wrap:wrap;flex-shrink:0}
.analytics-actions button{min-height:40px;padding:8px 14px;border:1px solid #a6b8dd;border-radius:8px;background:white;color:#233d72;cursor:pointer}
.analytics-actions button:focus-visible{outline:3px solid #3468e8;outline-offset:2px}
.analytics-actions button:disabled{opacity:.5;cursor:not-allowed}
@media(max-width:700px){.analytics-preferences{display:block}.analytics-actions{margin-top:14px}}
