/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --color-bg:         #f4f6f9;
  --color-surface:    #ffffff;
  --color-border:     #dde1e9;
  --color-primary:    #1a56db;
  --color-primary-h:  #1648c0;
  --color-text:       #111827;
  --color-muted:      #6b7280;
  --color-hit:        #dc2626;
  --color-hit-bg:     #fef2f2;
  --color-possible:   #d97706;
  --color-possible-bg:#fffbeb;
  --color-clear:      #16a34a;
  --color-clear-bg:   #f0fdf4;
  --radius:           8px;
  --shadow:           0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

a { color: var(--color-primary); }

.container { max-width: 1000px; margin: 0 auto; padding: 0 1.25rem; }

/* ── Header ── */
.site-header {
  background: var(--color-primary);
  color: #fff;
  padding: 1rem 0;
}
.site-header h1 { font-size: 1.6rem; font-weight: 700; }
.site-header .subtitle { font-size: .9rem; opacity: .85; margin-top: .2rem; }
.site-header .cache-notice { font-size: .78rem; opacity: .7; margin-top: .35rem; font-style: italic; }

/* ── Main layout ── */
main { padding: 2rem 0 3rem; display: flex; flex-direction: column; gap: 1.25rem; }

/* ── Card ── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

/* ── Tab group: zero gap so tabs touch the panel ── */
.tab-group { display: flex; flex-direction: column; }

/* ── Tabs ── */
.tabs { display: flex; gap: .5rem; }
.tab {
  padding: .55rem 1.1rem;
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid transparent;
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tab.active {
  color: var(--color-primary);
  border-color: var(--color-border);
  border-bottom-color: var(--color-surface);
  position: relative;
  bottom: -1px;
  z-index: 1;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Controls ── */
.controls { display: flex; flex-direction: column; gap: 1.25rem; margin-top: 5px; }

.control-label {
  display: block;
  font-weight: 600;
  font-size: .875rem;
  margin-bottom: .5rem;
  color: var(--color-text);
}

/* Algorithm chips */
.chip-group { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  padding: .35rem .85rem;
  border-radius: 999px;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
.chip.active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
}
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: .75rem;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  cursor: pointer;
}

/* Dual slider */
.slider-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  margin-bottom: .6rem;
  font-size: .8rem;
  color: var(--color-text);
}
.legend-item { display: flex; align-items: center; gap: .35rem; }
.legend-swatch {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}
.swatch-clear    { background: var(--color-clear); }
.swatch-possible { background: var(--color-possible); }
.swatch-hit      { background: var(--color-hit); }

.dual-slider-wrap {
  position: relative;
  height: 36px;
  max-width: 400px;
  display: flex;
  align-items: center;
}
.slider-colored-track {
  position: absolute;
  left: 0; right: 0;
  height: 6px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 0;
}
.range-input {
  position: absolute;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  pointer-events: none;
  height: 36px;
  margin: 0;
  z-index: 1;
}
.range-input:focus { outline: none; }
.range-input::-webkit-slider-runnable-track { background: transparent; }
.range-input::-moz-range-track { background: transparent; height: 6px; }

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 2;
}
.range-input::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
  cursor: pointer;
  pointer-events: auto;
}
#band-slider::-webkit-slider-thumb      { background: var(--color-possible); }
#band-slider::-moz-range-thumb          { background: var(--color-possible); }
#threshold-slider::-webkit-slider-thumb { background: var(--color-hit); }
#threshold-slider::-moz-range-thumb     { background: var(--color-hit); }

.threshold-labels {
  display: flex;
  justify-content: space-between;
  max-width: 400px;
  font-size: .75rem;
  color: var(--color-muted);
  margin-top: .25rem;
}

/* ── Forms ── */
.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  margin-bottom: .4rem;
}
.field input[type="text"] {
  width: 100%;
  max-width: 480px;
  padding: .6rem .875rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
}
.field input[type="text"]:focus { border-color: var(--color-primary); }

.btn-primary {
  padding: .6rem 1.4rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-h); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

/* ── Drop zone ── */
.drop-zone {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: .65rem 1rem;
  cursor: pointer;
  text-align: center;
  color: var(--color-muted);
  transition: border-color .15s, background .15s;
  margin-bottom: 1rem;
}
.drop-zone:hover,
.drop-zone.drag-over { border-color: var(--color-primary); background: #eff4ff; }
.drop-zone.has-file { border-style: solid; border-color: var(--color-primary); }

.upload-icon { width: 1.25rem; height: 1.25rem; fill: currentColor; flex-shrink: 0; }
.drop-label { font-size: .9rem; }
.file-selected { font-size: .875rem; color: var(--color-primary); font-weight: 500; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.help-text { font-size: .875rem; color: var(--color-muted); margin-bottom: 1rem; }

/* ── Status bar ── */
.status-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .875rem 1.25rem;
  font-weight: 500;
  color: var(--color-muted);
}
.status-error {
  border-color: var(--color-hit);
  background: var(--color-hit-bg);
  color: var(--color-hit);
}

.spinner {
  width: 1.25rem; height: 1.25rem;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Results ── */
#results-section {}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: .875rem;
}
.results-header h2 { font-size: 1.1rem; font-weight: 700; }
.results-count {
  font-size: .85rem;
  font-weight: 400;
  color: var(--color-muted);
  margin-left: .4rem;
}

.download-group { display: flex; align-items: center; gap: .5rem; font-size: .875rem; color: var(--color-muted); }
.btn-download {
  padding: .35rem .8rem;
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius);
  color: var(--color-primary);
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.btn-download:hover { background: var(--color-primary); color: #fff; }

/* Table */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--color-border); }
#results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  background: var(--color-surface);
}
#results-table th {
  text-align: left;
  padding: .65rem 1rem;
  background: #f8f9fb;
  border-bottom: 1px solid var(--color-border);
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-muted);
  white-space: nowrap;
}
#results-table td {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
#results-table tbody tr:last-child td { border-bottom: none; }
#results-table tbody tr:hover { background: #fafbfd; }

/* Verdict badges */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.badge-hit      { background: var(--color-hit-bg);      color: var(--color-hit); }
.badge-possible { background: var(--color-possible-bg); color: var(--color-possible); }
.badge-clear    { background: var(--color-clear-bg);    color: var(--color-clear); }


/* ── Responsive ── */
@media (max-width: 600px) {
  .results-header { flex-direction: column; align-items: flex-start; }
}

/* ── Footer ── */
.site-footer {
  margin-top: 2rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
}
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-bottom: .5rem;
  font-size: .85rem;
}
.footer-nav a {
  color: var(--color-muted);
  text-decoration: none;
}
.footer-nav a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}
.footer-copyright {
  font-size: .8rem;
  color: var(--color-muted);
}

/* ── Static content pages (How to Use, Privacy, Terms, About, Contact) ── */
.content-page h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 1.5rem 0 .5rem;
}
.content-page h2:first-child { margin-top: 0; }
.content-page p { margin-bottom: .9rem; line-height: 1.6; }
.content-page ul { margin: 0 0 .9rem 1.25rem; }
.content-page li { margin-bottom: .4rem; }
.disclaimer-banner {
  background: var(--color-possible-bg);
  color: var(--color-possible);
  border: 1px solid var(--color-possible);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .875rem;
  margin-bottom: 1.25rem;
}
