/* ── Design tokens ────────────────────────────────────────────────────────── */
:root {
  --bg:           #0f1117;
  --card:         #1a1d26;
  --card2:        #22263a;
  --ink:          #e8eaf0;
  --muted:        #7a8099;
  --accent:       #4d9fff;
  --accent-hover: #6ab2ff;
  --line:         #2d3148;
  --radius:       8px;
  --radius-sm:    4px;
  --success:      #3ecf8e;
  --warning:      #f5a623;
  --danger:       #ff5f5f;
  --code-bg:      #0a0c14;
  --code-text:    #a8c4ff;
  --max-w:        860px;
}

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
fieldset { border: none; padding: 0; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.app-header {
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 54px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
}

/* ── Wizard launch button (leftmost, prominent) ───────────────────────────── */
.wizard-launch-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.wizard-launch-btn:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--card));
}
.wizard-optional-tag {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  background: var(--card2);
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: .02em;
}

/* ── App title ────────────────────────────────────────────────────────────── */
.app-title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.tab-btn:hover  { color: var(--ink); background: var(--card2); }
.tab-btn.active { color: var(--accent); font-weight: 600; background: var(--card2); }

/* ── About button ─────────────────────────────────────────────────────────── */
.header-about-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  padding: 5px 12px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  flex-shrink: 0;
}
.header-about-btn:hover { color: var(--ink); border-color: var(--muted); }

/* ── Hamburger ────────────────────────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink);
  padding: 6px;
  border-radius: var(--radius-sm);
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

/* ── Nav drawer ───────────────────────────────────────────────────────────── */
.nav-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.55);
}
.nav-drawer-backdrop.open { display: block; }
.nav-drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 201;
  width: 270px;
  background: var(--card);
  border-right: 1px solid var(--line);
  transform: translateX(-100%);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.nav-drawer.open { transform: translateX(0); }
.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.nav-drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.1rem;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
}
.nav-drawer-close:hover { color: var(--ink); background: var(--card2); }
.nav-drawer-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 18px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  transition: background .15s;
}
.nav-drawer-item:hover { background: var(--card2); }
.nav-drawer-item.active { background: var(--card2); font-weight: 600; color: var(--accent); }
.nav-drawer-wizard {
  color: var(--accent);
  font-weight: 600;
}
.nav-drawer-about {
  margin-top: auto;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.nav-drawer-about strong {
  display: block;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 4px;
}
.nav-drawer-links {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-drawer-links a { color: var(--muted); font-size: 12px; }
.nav-drawer-links a:hover { color: var(--accent); }

/* ── Image loader ─────────────────────────────────────────────────────────── */
.fts-loader {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 20px 24px;
  width: 100%;
}
.fts-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 24px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--bg);
}
.fts-dropzone:hover,
.fts-dropzone.drag-over { border-color: var(--accent); background: var(--card2); }
.fts-dropzone-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.fts-dropzone-icon { font-size: 2.5rem; }
.fts-drop-text { font-size: 1.1rem; font-weight: 600; color: var(--ink); }
.fts-drop-hint { font-size: 12px; color: var(--muted); max-width: 340px; line-height: 1.5; }
.fts-loaded-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 11px 16px;
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.fts-loaded-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fts-loaded-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fts-loaded-meta { font-size: 12px; color: var(--muted); }

/* ── Wizard bar ───────────────────────────────────────────────────────────── */
.wizard-overlay { /* wrapper — currently just holds the bar */ }
.wizard-bar {
  background: var(--card);
  border-bottom: 2px solid var(--accent);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.wizard-step-info { display: flex; flex-direction: column; gap: 1px; min-width: 160px; }
.wizard-step-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.wizard-step-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.wizard-dots { display: flex; gap: 6px; align-items: center; }
.wizard-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--line);
  transition: background .2s;
}
.wizard-dot.active { background: var(--accent); }
.wizard-dot.done   { background: var(--success); }
.wizard-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }

/* ── Panels ───────────────────────────────────────────────────────────────── */
.panels-container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 28px 24px;
  width: 100%;
  flex: 1;
}
.panel { display: none; }
.panel.visible { display: block; }
.panel-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--ink);
}

/* ── Section label ────────────────────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 20px 0 10px;
}
.section-label:first-child { margin-top: 0; }

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}

/* ── Chips ────────────────────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  padding: 5px 13px;
  transition: color .15s, border-color .15s, background .15s;
}
.chip:hover  { color: var(--ink); border-color: var(--muted); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ── Controls ─────────────────────────────────────────────────────────────── */
.controls-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.control-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.export-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 20px;
  transition: background .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.export-btn:hover    { background: var(--accent-hover); }
.export-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.export-btn-secondary {
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  padding: 8px 16px;
  transition: border-color .15s, background .15s;
}
.export-btn-secondary:hover { border-color: var(--muted); background: var(--card2); }
.text-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  transition: color .15s;
}
.text-btn:hover { color: var(--ink); }

/* ── Notices & warnings ───────────────────────────────────────────────────── */
.fts-notice {
  background: var(--card2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}
.fts-notice strong { color: var(--ink); }
.fts-warn {
  background: color-mix(in srgb, var(--warning) 10%, var(--card2));
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  margin-bottom: 12px;
}
.fts-warn strong { color: var(--ink); }

/* ── Explanation toggle ───────────────────────────────────────────────────── */
.tool-explain-wrap { margin-bottom: 20px; }
.tool-explain-toggle {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color .15s;
}
.tool-explain-toggle:hover { color: var(--accent); }
.tool-explain {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--code-bg);
}
.tool-explain p { margin-bottom: 8px; }
.tool-explain p:last-child { margin-bottom: 0; }
.tool-explain strong { color: var(--ink); }

/* ── Forensic flag badges ─────────────────────────────────────────────────── */
.flags-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.flag-badge {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
}
.flag-badge.green  { background: color-mix(in srgb, var(--success) 12%, var(--card)); border-left: 3px solid var(--success); color: var(--ink); }
.flag-badge.yellow { background: color-mix(in srgb, var(--warning) 12%, var(--card)); border-left: 3px solid var(--warning); color: var(--ink); }
.flag-badge.red    { background: color-mix(in srgb, var(--danger)  12%, var(--card)); border-left: 3px solid var(--danger);  color: var(--ink); }

/* ── Metadata table ───────────────────────────────────────────────────────── */
.meta-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 12px;
}
.meta-table td, .meta-table th {
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.meta-table tr:last-child td { border-bottom: none; }
.meta-key {
  color: var(--muted);
  background: var(--code-bg);
  white-space: nowrap;
  font-weight: 500;
  width: 180px;
}
.meta-val {
  color: var(--ink);
  word-break: break-all;
  font-family: 'SF Mono', 'Fira Mono', monospace;
}
.meta-group-label {
  background: var(--card2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
}

/* ── Canvas wrapper ───────────────────────────────────────────────────────── */
.fts-canvas-wrap {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  line-height: 0;
  margin-top: 16px;
}
.fts-canvas-wrap canvas { display: block; width: 100%; height: auto; }

/* ── Progress ─────────────────────────────────────────────────────────────── */
.progress-wrap { margin: 16px 0; }
.progress-bar-bg {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width .3s;
}
.progress-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}
.result-caption {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

/* ── Checkbox / radio labels ──────────────────────────────────────────────── */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}
.checkbox-label input { accent-color: var(--accent); }

/* ── Strip options ────────────────────────────────────────────────────────── */
.strip-options { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.strip-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
}
.strip-option:hover { background: var(--card2); }
.strip-option input[type=radio] { accent-color: var(--accent); margin-top: 2px; flex-shrink: 0; }
.strip-option-text { display: flex; flex-direction: column; gap: 2px; }
.strip-option-text strong { font-size: 13px; color: var(--ink); font-weight: 600; }
.strip-option-text span { font-size: 12px; color: var(--muted); }
.strip-summary {
  font-size: 13px;
  color: var(--muted);
  padding: 10px 14px;
  background: var(--card2);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.strip-summary strong { color: var(--success); }

/* ── Range slider ─────────────────────────────────────────────────────────── */
input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  background: var(--line);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

/* ── Report ───────────────────────────────────────────────────────────────── */
.report-checklist { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.report-status-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}
.report-preview {
  padding: 20px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
}

/* ── About modal ──────────────────────────────────────────────────────────── */
.about-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.about-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
}
.about-modal-box {
  position: relative;
  z-index: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}
.about-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--card);
}
.about-modal-header h2 { font-size: 15px; font-weight: 600; }
.about-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.2rem;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
}
.about-modal-close:hover { background: var(--card2); color: var(--ink); }
.about-modal-body {
  padding: 20px 24px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}
.about-modal-body h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink);
  margin: 18px 0 8px;
}
.about-modal-body h3:first-child { margin-top: 0; }
.about-modal-body p { margin: 0 0 10px; }
.about-modal-body strong { color: var(--ink); }
.about-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.about-links a { color: var(--accent); }

/* ── Site footer ──────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}
.footer-privacy { color: var(--muted); }
.footer-links { display: flex; align-items: center; gap: 8px; }
.footer-links a { color: var(--muted); transition: color .15s; }
.footer-links a:hover { color: var(--ink); text-decoration: none; }
.footer-sep { color: var(--line); }

/* ── Print ────────────────────────────────────────────────────────────────── */
@media print {
  .app-header, .fts-loader, .wizard-overlay, .site-footer,
  .nav-drawer, .nav-drawer-backdrop, .about-modal,
  .tool-explain-wrap, .export-btn, .export-btn-secondary,
  .chips, .controls-row { display: none !important; }
  body { background: #fff; color: #000; font-size: 12px; }
  .panel { display: block !important; }
  .panels-container { padding: 0; max-width: 100%; }
  .report-preview { background: #fff; border: none; padding: 0; }
  .fts-canvas-wrap canvas { max-width: 100%; page-break-inside: avoid; }
  .flag-badge { border: 1px solid #ccc; }
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .tabs { display: none; }
  .nav-hamburger { display: flex; }
  .wizard-launch-btn .wizard-optional-tag { display: none; }
  .app-header { padding: 0 14px; gap: 10px; }
  .header-about-btn { display: none; }
  .panels-container { padding: 20px 16px; }
  .fts-loader { padding: 16px; }
  .site-footer { flex-direction: column; align-items: flex-start; gap: 8px; }
}
@media (max-width: 480px) {
  .wizard-launch-btn { font-size: 12px; padding: 5px 10px; }
  .controls-row { flex-direction: column; gap: 14px; }
  .fts-loaded-bar { flex-direction: column; align-items: flex-start; }
  .wizard-actions { flex-wrap: wrap; gap: 6px; }
  .meta-key { width: 120px; }
}
