@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #08111f;
  --bg-deep: #050914;
  --panel: rgba(16, 24, 39, 0.92);
  --panel-soft: rgba(12, 20, 34, 0.82);
  --panel-strong: rgba(7, 14, 24, 0.92);
  --border: #2d3c5a;
  --border-soft: #22314d;
  --text: #edf4ff;
  --muted: #9db0cb;
  --accent: #5aa9ff;
  --accent-soft: #8bd4ff;
  --safe: #3dd68c;
  --warn: #f6b73c;
  --danger: #ff5a6b;
  --shadow: 0 20px 44px rgba(0, 0, 0, 0.3);
  --radius: 16px;
  --radius-sm: 12px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: radial-gradient(circle at top, #18253e 0%, var(--bg) 58%, var(--bg-deep) 100%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(139, 212, 255, 0.05), rgba(139, 212, 255, 0.015)),
    repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(139, 212, 255, 0.04) 32px),
    repeating-linear-gradient(90deg, transparent 0, transparent 31px, rgba(139, 212, 255, 0.025) 32px);
  opacity: 0.38;
}

/* ── Layout ───────────────────────────────────────────────────── */

.container {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 12px env(safe-area-inset-bottom, 16px);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.hero-card {
  background:
    linear-gradient(180deg, rgba(139, 212, 255, 0.06) 0%, rgba(16, 24, 39, 0.92) 40%),
    var(--panel);
}

/* ── Typography ───────────────────────────────────────────────── */

h1, h2, h3, h4 { margin-top: 0; color: var(--text); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; margin-bottom: 12px; }
h3 { font-size: 1.05rem; margin: 18px 0 10px; }

p, li, strong, summary, label, small, span { line-height: 1.55; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-soft);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 700;
}
.eyebrow.small { margin-bottom: 4px; font-size: 0.66rem; }

.lead { max-width: 700px; font-size: 0.98rem; }
.muted { color: var(--muted); }

/* ── Mode cards ───────────────────────────────────────────────── */

.mode-cards {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
}

.mode-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.mode-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #03101d;
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mode-card strong { display: block; margin-bottom: 2px; font-size: 0.92rem; }
.mode-card span { color: var(--muted); font-size: 0.84rem; }

/* ── Form ─────────────────────────────────────────────────────── */

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 5px; font-weight: 600; font-size: 0.92rem; }

input[type="file"],
input[type="number"],
input[type="url"],
input[type="text"],
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  background: rgba(7, 14, 24, 0.86);
  color: var(--text);
  font-size: 16px; /* Prevents iOS zoom */
}

input[type="file"] {
  border-style: dashed;
  border-color: rgba(90, 169, 255, 0.35);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
input[type="file"]:hover,
input[type="file"]:focus {
  border-color: rgba(90, 169, 255, 0.6);
  background: rgba(90, 169, 255, 0.05);
}

input::file-selector-button {
  border: 0;
  border-radius: 10px;
  margin-right: 10px;
  padding: 9px 12px;
  background: rgba(90, 169, 255, 0.16);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}

select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239db0cb'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

input:focus, select:focus, button:focus, summary:focus {
  outline: 2px solid rgba(139, 212, 255, 0.5);
  outline-offset: 2px;
}

.field small.muted { display: block; margin-top: 4px; font-size: 0.8rem; line-height: 1.4; }

/* ── Buttons ──────────────────────────────────────────────────── */

button {
  border: 1px solid rgba(90, 169, 255, 0.2);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #4d96ef 0%, #5aa9ff 100%);
  color: #03101d;
  padding: 13px 20px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(25, 82, 151, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(25, 82, 151, 0.3);
}
button:active:not(:disabled) { transform: scale(0.98); }

button:disabled {
  background: rgba(84, 106, 143, 0.5);
  border-color: rgba(84, 106, 143, 0.5);
  color: rgba(237, 244, 255, 0.6);
  cursor: not-allowed;
  box-shadow: none;
}

button.secondary {
  background: rgba(90, 169, 255, 0.12);
  color: var(--text);
  box-shadow: none;
  width: auto;
  padding: 10px 16px;
  font-size: 0.9rem;
}

/* ── Inline row ───────────────────────────────────────────────── */

.inline-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0;
}

/* ── Error ────────────────────────────────────────────────────── */

.error {
  display: block;
  margin-top: 10px;
  padding: 10px 14px;
  color: #ff8c9f;
  background: rgba(255, 90, 107, 0.08);
  border: 1px solid rgba(255, 90, 107, 0.3);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
}

/* ── Status pill ──────────────────────────────────────────────── */

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid rgba(90, 169, 255, 0.3);
  background: rgba(90, 169, 255, 0.12);
  color: var(--accent-soft);
}
.status-pill.online {
  border-color: rgba(61, 214, 140, 0.35);
  background: rgba(61, 214, 140, 0.12);
  color: #9ff5c7;
}
.status-pill.attention {
  border-color: rgba(246, 183, 60, 0.35);
  background: rgba(246, 183, 60, 0.12);
  color: #ffd98d;
}

/* ── Verdict badge ────────────────────────────────────────────── */

.verdict-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.verdict-badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: #6f7d97;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  font-size: 0.92rem;
}

/* ── Advanced panels ──────────────────────────────────────────── */

.advanced {
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(7, 14, 24, 0.84);
  overflow: hidden;
}

.advanced summary {
  cursor: pointer;
  list-style: none;
  padding: 13px 16px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.92rem;
  -webkit-tap-highlight-color: transparent;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::after {
  content: '\25BE';
  float: right;
  color: var(--muted);
  transition: transform 0.2s;
}
details[open] > summary::after { transform: rotate(-180deg); }

.adv-body { padding: 0 16px 16px; }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.settings-grid .full-width { grid-column: 1 / -1; }

/* ── Progress ─────────────────────────────────────────────────── */

.progress-track,
.meter-track,
.bar-track {
  width: 100%;
  background: var(--panel-strong);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
}

.progress-track { height: 12px; }

.progress-bar {
  width: 0;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #8bd4ff 0%, #5aa9ff 60%, #3dd68c 100%);
  transition: width 0.25s linear;
  position: relative;
  overflow: hidden;
}
.progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.25) 40%, rgba(255,255,255,0.1) 55%, transparent 100%);
  animation: shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* ── Check status list ────────────────────────────────────────── */

.check-list {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.check-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.2s, border-color 0.2s;
}

.check-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(90, 169, 255, 0.1);
  color: var(--muted);
}

.check-status.running { color: var(--accent-soft); border-color: rgba(90, 169, 255, 0.4); }
.check-status.running .check-icon { background: rgba(90, 169, 255, 0.25); color: var(--accent); animation: pulse-icon 1s infinite; }

.check-status.done { color: var(--safe); border-color: rgba(61, 214, 140, 0.3); }
.check-status.done .check-icon { background: rgba(61, 214, 140, 0.2); color: var(--safe); }

.check-status.error { color: var(--danger); border-color: rgba(255, 90, 107, 0.3); }
.check-status.error .check-icon { background: rgba(255, 90, 107, 0.2); color: var(--danger); }

@keyframes pulse-icon {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Metrics ──────────────────────────────────────────────────── */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.metric-card {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  border-top: 2px solid var(--border);
}
.metric-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.metric-card h3 { margin: 6px 0 0; font-size: 1.3rem; }

.meter-track { height: 14px; margin-top: 12px; }
.meter-fill {
  width: 0%;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #3dd68c 0%, #f6b73c 55%, #ff5a6b 100%);
  transition: width 0.4s ease;
}

.sha-line {
  margin-top: 10px;
  font-size: 0.82rem;
  word-break: break-all;
}
.sha-line code {
  background: rgba(7, 14, 24, 0.86);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.78rem;
}

/* ── Check bars (results) ─────────────────────────────────────── */

.check-bars { display: grid; gap: 10px; margin-bottom: 12px; }

.check-item {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.check-item h4 { margin: 0 0 4px; font-size: 0.96rem; }
.check-summary { font-size: 0.86rem; margin: 6px 0 0; }

.bar-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 0.84rem;
  margin-bottom: 6px;
  color: var(--muted);
}

.bar-fill-score {
  height: 10px;
  background: var(--danger);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.bar-fill-confidence {
  height: 10px;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ── Timeline ─────────────────────────────────────────────────── */

.timeline-track {
  position: relative;
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(90deg, rgba(90, 169, 255, 0.06), rgba(90, 169, 255, 0.02)),
    rgba(7, 14, 24, 0.86);
  margin-bottom: 8px;
}

.timeline-block {
  position: absolute;
  top: 4px;
  height: 24px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(246, 183, 60, 0.88), rgba(255, 90, 107, 0.94));
  box-shadow: 0 0 14px rgba(255, 90, 107, 0.2);
  opacity: 0.85;
  cursor: pointer;
}
.timeline-block:hover { transform: scaleY(1.15); opacity: 1; transition: transform 0.1s, opacity 0.1s; }

/* ── Raw data ─────────────────────────────────────────────────── */

#result-raw {
  max-height: 260px;
  overflow: auto;
  background: rgba(5, 12, 22, 0.96);
  color: #dce9ff;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  line-height: 1.5;
  -webkit-overflow-scrolling: touch;
}

/* ── Footer ───────────────────────────────────────────────────── */

.footer {
  text-align: center;
  padding: 20px 0 10px;
  font-size: 0.82rem;
}

/* ── Hidden ───────────────────────────────────────────────────── */

.hidden { display: none !important; }

/* ── Mobile responsive ────────────────────────────────────────── */

@media (max-width: 600px) {
  body { font-size: 14px; }
  h1 { font-size: 1.35rem; }
  .container { padding: 10px 8px; }
  .card { padding: 16px 12px; border-radius: 14px; }

  .mode-cards { gap: 8px; }
  .mode-card { padding: 10px; }

  .metric-grid { grid-template-columns: 1fr; gap: 8px; }
  .settings-grid { grid-template-columns: 1fr; }

  .bar-row { grid-template-columns: 1fr; gap: 3px; }
  .bar-row span { font-size: 0.78rem; }

  .inline-row { flex-direction: column; align-items: stretch; }
  .inline-row button { width: 100%; }
  .inline-row .status-pill { text-align: center; justify-content: center; }

  button { padding: 14px 16px; }
  button.secondary { width: 100%; }

  .check-status { padding: 7px 10px; font-size: 0.82rem; }
}

@media (min-width: 600px) {
  .mode-cards {
    grid-template-columns: repeat(3, 1fr);
  }
  .metric-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  .container {
    padding: 24px 16px;
  }
  h1 { font-size: 1.65rem; }
  .card { padding: 22px 20px; }
}

/* ── Touch-friendly tap targets ───────────────────────────────── */
@media (pointer: coarse) {
  input[type="file"],
  input[type="number"],
  input[type="url"],
  select,
  button,
  summary {
    min-height: 48px;
  }
  .check-status { min-height: 44px; }
}

/* ── Safe area insets (notch phones) ──────────────────────────── */
@supports (padding: env(safe-area-inset-left)) {
  .container {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
}
