/* ==========================================================================
   Mobile IC Decoder — Stylesheet
   Dark, premium, technician-grade. Blue/cyan accent on near-black navy.
   ========================================================================== */

:root {
  /* Palette */
  --bg-void: #05070c;
  --bg-navy: #0a1120;
  --bg-panel: #0e1728;
  --bg-panel-raised: #121d33;
  --line: rgba(120, 170, 255, 0.14);
  --line-strong: rgba(120, 170, 255, 0.28);
  --text-primary: #eaf1ff;
  --text-secondary: #93a5c4;
  --text-muted: #5b6c8a;
  --accent: #35c5ff;
  --accent-soft: #7fdcff;
  --accent-dim: rgba(53, 197, 255, 0.14);
  --ok: #3ee08b;
  --ok-dim: rgba(62, 224, 139, 0.12);
  --warn: #ffb545;
  --warn-dim: rgba(255, 181, 69, 0.12);
  --danger: #ff6b6b;
  --danger-dim: rgba(255, 107, 107, 0.12);
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 22px;
  --shadow-panel: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html { color-scheme: dark; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text-primary);
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(53, 197, 255, 0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(53, 197, 255, 0.06), transparent 55%),
    var(--bg-void);
  -webkit-font-smoothing: antialiased;
}

/* Faint circuit-trace texture behind everything, purely decorative */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(1100px 700px at 50% 0%, black, transparent 70%);
}

a { color: inherit; }
button { font-family: inherit; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #001018;
  padding: 10px 16px;
  border-radius: var(--radius-s);
  z-index: 100;
}
.skip-link:focus { left: 16px; top: 16px; }

:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: rgba(5, 7, 12, 0.72);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, var(--bg-panel-raised), var(--bg-panel));
  border: 1px solid var(--line-strong);
  color: var(--accent-soft);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.01em; }
.brand-tag { font-family: var(--mono); font-size: 10.5px; color: var(--text-muted); letter-spacing: 0.04em; text-transform: uppercase; }

.main-nav { display: flex; gap: 4px; }
.main-nav a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  transition: color 0.15s ease, background 0.15s ease;
}
.main-nav a:hover, .main-nav a:focus-visible { color: var(--text-primary); background: var(--bg-panel); }
.main-nav a.active { color: var(--accent-soft); background: var(--accent-dim); }

/* ---------- Hero ---------- */
.hero { padding: 56px 0 28px; text-align: center; }
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-soft);
  background: var(--accent-dim);
  border: 1px solid rgba(53, 197, 255, 0.25);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 20px;
}
.hero-eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(30px, 5.4vw, 46px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  font-weight: 700;
}
.hero h1 .accent { color: var(--accent-soft); }
.hero p {
  margin: 0 auto;
  max-width: 540px;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.55;
}

/* ---------- Panels ---------- */
.panel {
  position: relative;
  background: linear-gradient(180deg, var(--bg-panel-raised), var(--bg-panel));
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-panel);
  padding: 28px;
  margin: 20px 0;
}
.panel::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, rgba(53,197,255,0.35), transparent 40%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}
.panel-head { margin-bottom: 18px; }
.panel-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 6px;
}
.panel-title { margin: 0 0 6px; font-size: 22px; font-weight: 700; }
.panel-desc { margin: 0; color: var(--text-secondary); font-size: 14.5px; }

/* ---------- Search card ---------- */
.search-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.input-shell {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-navy);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-m);
  padding: 0 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-shell:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}
.input-shell svg { flex-shrink: 0; color: var(--text-muted); }
#ic-input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.02em;
  padding: 16px 0;
  min-width: 0;
}
#ic-input::placeholder { color: var(--text-muted); font-family: var(--sans); letter-spacing: normal; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  font-weight: 600;
  font-size: 14.5px;
  padding: 0 22px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.1s ease, filter 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  color: #001522;
  box-shadow: 0 10px 24px -8px rgba(53, 197, 255, 0.55);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
  background: var(--bg-panel);
  color: var(--text-secondary);
  border-color: var(--line-strong);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--accent); }
.btn-sm { padding: 0 14px; height: 38px; font-size: 13px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.search-row .btn { height: 54px; }

.hint-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.hint-chip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  border: 1px dashed var(--line-strong);
  border-radius: 999px;
  padding: 5px 11px;
}

/* ---------- Results ---------- */
#result-region { margin-top: 22px; }

.result-card {
  border-radius: var(--radius-l);
  border: 1px solid var(--line-strong);
  overflow: hidden;
  animation: rise 0.35s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.result-found { background: linear-gradient(180deg, rgba(62,224,139,0.07), var(--bg-panel)); border-color: rgba(62,224,139,0.35); }
.result-possible { background: linear-gradient(180deg, rgba(255,181,69,0.07), var(--bg-panel)); border-color: rgba(255,181,69,0.35); }
.result-missing { background: linear-gradient(180deg, rgba(255,107,107,0.06), var(--bg-panel)); border-color: rgba(255,107,107,0.3); }

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
}
.result-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}
.result-found .result-status { color: var(--ok); }
.result-possible .result-status { color: var(--warn); }
.result-missing .result-status { color: var(--danger); }

.result-code { margin: 8px 0 0; font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: 0.01em; word-break: break-word; }
.result-subline { margin: 6px 0 0; color: var(--text-secondary); font-size: 14.5px; }

.verify-badge {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--ok-dim);
  color: var(--ok);
  border: 1px solid rgba(62,224,139,0.35);
  white-space: nowrap;
}

.result-body { padding: 22px 26px 26px; }

.spec-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  overflow: hidden;
  margin-bottom: 18px;
}
.spec-cell { background: var(--bg-navy); padding: 14px 16px; }
.spec-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 6px; }
.spec-value { margin: 0; font-size: 15px; font-weight: 600; word-break: break-word; }
.spec-value.mono { font-family: var(--mono); font-size: 14px; }
.spec-cell.wide { grid-column: 1 / -1; }

.rom-ram-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.rr-card { border-radius: var(--radius-m); padding: 16px; border: 1px solid var(--line-strong); background: var(--bg-navy); }
.rr-card .rr-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 8px; }
.rr-card .rr-value { font-size: 22px; font-weight: 700; margin: 0; }
.rr-card.storage { border-color: rgba(53,197,255,0.35); }
.rr-card.storage .rr-value { color: var(--accent-soft); }
.rr-card.ram .rr-value.unknown { color: var(--text-muted); font-size: 16px; font-weight: 600; }

.explain-box {
  background: var(--bg-navy);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 18px;
}
.explain-box strong { color: var(--text-primary); }

.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.suggestion-list { margin: 14px 0 0; padding-left: 20px; color: var(--text-secondary); font-size: 14px; line-height: 1.7; }

.candidate-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.candidate-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; text-align: left;
  background: var(--bg-navy);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-m);
  padding: 12px 16px;
  color: var(--text-primary);
  cursor: pointer;
}
.candidate-btn:hover { border-color: var(--warn); }
.candidate-btn .cand-code { font-family: var(--mono); font-weight: 700; }
.candidate-btn .cand-meta { color: var(--text-muted); font-size: 12.5px; }

.verify-note {
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--line);
  padding-top: 14px;
  line-height: 1.6;
}

/* Empty / loading states inside result region */
.state-box {
  padding: 40px 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-l);
  color: var(--text-muted);
}
.state-box svg { margin-bottom: 10px; color: var(--text-muted); }
.state-box p { margin: 0; font-size: 14px; }

.spinner {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(53,197,255,0.25);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- OCR / Scan panel ---------- */
.upload-zone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-m);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  background: var(--bg-navy);
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); background: var(--accent-dim); }
.upload-zone svg { color: var(--accent-soft); margin-bottom: 10px; }
.upload-zone p { margin: 0; font-size: 14px; color: var(--text-secondary); }
.upload-zone .upload-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
#ic-photo-input { display: none; }

.scan-preview { margin-top: 18px; display: none; gap: 18px; }
.scan-preview.active { display: grid; grid-template-columns: 140px 1fr; }
.scan-preview img { width: 140px; height: 140px; object-fit: cover; border-radius: var(--radius-m); border: 1px solid var(--line-strong); }
.scan-preview-body { display: flex; flex-direction: column; gap: 10px; }
.ocr-status { font-family: var(--mono); font-size: 12.5px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.ocr-progress { height: 4px; border-radius: 4px; background: var(--bg-panel); overflow: hidden; }
.ocr-progress-bar { height: 100%; width: 0%; background: var(--accent); transition: width 0.2s ease; }

.detected-row { display: flex; gap: 10px; }
.detected-row input {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 14px;
}
.ocr-low-conf { color: var(--warn); font-size: 12.5px; }

@media (max-width: 620px) {
  .scan-preview.active { grid-template-columns: 1fr; }
  .scan-preview img { width: 100%; height: 160px; }
}

/* ---------- Examples ---------- */
.example-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.example-chip {
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--bg-navy);
  border: 1px solid var(--line-strong);
  color: var(--accent-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.example-chip:hover { border-color: var(--accent); background: var(--accent-dim); }

/* ---------- History ---------- */
.history-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.history-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-navy);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  cursor: pointer;
}
.history-item:hover { border-color: var(--accent); }
.history-main { display: flex; flex-direction: column; gap: 2px; }
.history-code { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.history-meta { font-size: 12px; color: var(--text-muted); }
.history-status { font-size: 11px; font-family: var(--mono); padding: 3px 9px; border-radius: 999px; }
.history-status.found { background: var(--ok-dim); color: var(--ok); }
.history-status.possible { background: var(--warn-dim); color: var(--warn); }
.history-status.not_found { background: var(--danger-dim); color: var(--danger); }
.history-empty { color: var(--text-muted); font-size: 13.5px; margin-top: 12px; }
.history-head-row { display: flex; align-items: center; justify-content: space-between; }

/* ---------- Supported types ---------- */
.types-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.type-card { background: var(--bg-navy); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px; }
.type-card h3 { margin: 0 0 6px; font-size: 15px; font-family: var(--mono); color: var(--accent-soft); }
.type-card p { margin: 0; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 16px; }
.about-card { background: var(--bg-navy); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px; }
.about-card h3 { margin: 0 0 8px; font-size: 15px; }
.about-card p, .about-card li { font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; }
.about-card ul { margin: 0; padding-left: 18px; }

.disclaimer {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: var(--radius-m);
  border: 1px solid rgba(255, 181, 69, 0.35);
  background: var(--warn-dim);
  color: #ffd8a3;
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- Footer ---------- */
.site-footer { margin-top: 40px; border-top: 1px solid var(--line); padding: 26px 0 60px; }
.site-footer .wrap { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.site-footer p { margin: 0; color: var(--text-muted); font-size: 12.5px; }
.footer-install-btn { display: none; }
.footer-install-btn.show { display: inline-flex; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: var(--bg-panel-raised);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  display: flex; align-items: center; gap: 8px;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .main-nav { display: none; }
  .search-row { flex-direction: column; }
  .search-row .btn { height: 50px; width: 100%; justify-content: center; }
  .spec-grid { grid-template-columns: 1fr; }
  .rom-ram-row { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; }
  .panel { padding: 20px; border-radius: var(--radius-m); }
  .result-header { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
