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

:root {
  --bg: #0d0f14;
  --bg2: #13161e;
  --bg3: #1a1e29;
  --border: #252a38;
  --accent: #4f7cff;
  --accent2: #7c5fff;
  --text: #e8eaf0;
  --text2: #8890a4;
  --text3: #555d72;
  --danger: #ff4d6d;
  --warn: #f59e0b;
  --success: #10b981;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Header ── */
.header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 100;
}

.header-inner {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
}

.logo { display: flex; align-items: center; gap: 0.65rem; }
.logo-icon { font-size: 1.5rem; }
.logo h1 { font-size: 1.1rem; font-weight: 700; }
.header-sub { font-size: 0.7rem; color: var(--text2); margin-top: 1px; }

.badge {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ── Main layout ── */
.main {
  flex: 1;
  max-width: 880px;
  margin: 1.5rem auto;
  padding: 0 1.25rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.subtitle {
  color: var(--text2);
  font-size: 0.8rem;
  margin-bottom: 1.25rem;
}

/* ── QR Panel ── */
.qr-panel { padding: 1.5rem; }

.qr-inner {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.qr-left { flex: 1; }
.qr-left h2 { font-size: 1.15rem; margin-bottom: 0.4rem; }
.qr-left p { font-size: 0.85rem; color: var(--text2); margin-bottom: 1rem; }

.qr-url-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1.25rem;
}

.qr-url-box code {
  flex: 1;
  font-size: 0.72rem;
  color: var(--accent);
  font-family: 'SF Mono', Consolas, monospace;
  word-break: break-all;
}

.iphone-steps { display: flex; flex-direction: column; gap: 0.5rem; }

.step {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--text2);
}

.step-num {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.qr-right { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }

.qr-wrap {
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-wrap img { width: 140px; height: 140px; display: block; }

.qr-caption { font-size: 0.72rem; color: var(--text3); text-align: center; }

/* ── iPhone hint (mobile only) ── */
.iphone-hint { padding: 1rem 1.25rem; }

.iphone-hint-inner {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.hint-icon { font-size: 1.75rem; flex-shrink: 0; margin-top: 2px; }

.iphone-hint strong { display: block; font-size: 0.9rem; margin-bottom: 0.2rem; }
.iphone-hint p { font-size: 0.8rem; color: var(--text2); }

/* ── Upload ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 1rem;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(79, 124, 255, 0.05);
}

.upload-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.upload-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.2rem; }
.upload-sub { color: var(--text2); font-size: 0.82rem; margin-bottom: 1.25rem; }

.file-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  margin-bottom: 0.75rem;
}

.file-name-icon { font-size: 1.25rem; flex-shrink: 0; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { color: var(--text2); font-size: 0.78rem; }

.upload-actions { display: flex; justify-content: center; margin-top: 0.75rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled { opacity: 0.38; cursor: not-allowed; }

.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }

.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); }

.btn-lg { font-size: 1rem; padding: 0.7rem 1.75rem; }
.btn-sm { font-size: 0.8rem; padding: 0.4rem 0.9rem; }
.btn-full { width: 100%; font-size: 1rem; padding: 0.85rem; border-radius: 10px; }

/* ── Capabilities ── */
.capabilities { margin-top: 1.75rem; }
.capabilities h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.capabilities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.4rem;
}

.cap-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text2);
  background: var(--bg3);
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ── Progress ── */
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text2);
  margin-bottom: 0.4rem;
}

#progress-pct { font-family: 'SF Mono', Consolas, monospace; font-weight: 600; color: var(--accent); }

.progress-bar-wrap {
  height: 6px;
  background: var(--bg3);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 999px;
  width: 0%;
  transition: width 0.5s ease;
}

.log-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.875rem;
  height: 260px;
  overflow-y: auto;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 0.76rem;
  color: var(--text2);
}

.log-entry { padding: 2px 0; line-height: 1.5; }
.log-entry.info { color: var(--text2); }
.log-entry.warn { color: var(--warn); }
.log-entry.error { color: var(--danger); }
.log-entry.success { color: var(--success); }

.progress-note { color: var(--text3); font-size: 0.76rem; margin-top: 0.65rem; text-align: center; }

/* ── Result ── */
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.result-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.verdict-banner {
  padding: 0.875rem 1.1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  border: 1px solid;
}

.verdict-banner.danger  { background: rgba(255,77,109,.1); border-color: var(--danger); color: var(--danger); }
.verdict-banner.warning { background: rgba(245,158,11,.1); border-color: var(--warn); color: var(--warn); }
.verdict-banner.moderate{ background: rgba(79,124,255,.1); border-color: var(--accent); color: var(--accent); }
.verdict-banner.safe    { background: rgba(16,185,129,.1); border-color: var(--success); color: var(--success); }

.tabs {
  display: flex;
  gap: 0.15rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.tab {
  background: none;
  border: none;
  color: var(--text2);
  padding: 0.55rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.18s;
  font-family: inherit;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: block; }
.tab-content.hidden { display: none; }

/* ── Report rendering ── */
.report-content { font-size: 0.875rem; line-height: 1.7; }
.report-content h1 { font-size: 1.35rem; margin: 1.5rem 0 0.6rem; color: var(--accent); }
.report-content h2 { font-size: 1.1rem; margin: 1.35rem 0 0.6rem; color: var(--text); padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); }
.report-content h3 { font-size: 0.95rem; margin: 1rem 0 0.4rem; color: var(--text2); }
.report-content p { margin-bottom: 0.65rem; }
.report-content ul, .report-content ol { padding-left: 1.35rem; margin-bottom: 0.65rem; }
.report-content li { margin-bottom: 0.2rem; }
.report-content hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

.report-content code {
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 0.8em;
  color: #a5f3fc;
  word-break: break-all;
}

.report-content pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 0.78rem;
}

.report-content pre code { background: none; border: none; padding: 0; color: var(--text); }

.report-content table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; font-size: 0.8rem; overflow-x: auto; display: block; }
.report-content th { background: var(--bg3); padding: 0.45rem 0.7rem; text-align: left; border: 1px solid var(--border); color: var(--text2); font-weight: 600; }
.report-content td { padding: 0.35rem 0.7rem; border: 1px solid var(--border); vertical-align: top; }
.report-content tr:hover td { background: rgba(255,255,255,.02); }

.raw-report {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 0.76rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text2);
  max-height: 650px;
  overflow-y: auto;
  line-height: 1.6;
}

/* ── Summary grid ── */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.875rem; }

.summary-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  text-align: center;
}

.summary-card .num { font-size: 1.85rem; font-weight: 700; font-family: 'SF Mono', Consolas, monospace; }
.summary-card .num.red    { color: var(--danger); }
.summary-card .num.orange { color: var(--warn); }
.summary-card .num.blue   { color: var(--accent); }
.summary-card .num.green  { color: var(--success); }
.summary-card .label { font-size: 0.75rem; color: var(--text2); margin-top: 0.2rem; }

/* ── Error ── */
.error-card { border-color: var(--danger); }
.error-card h2 { color: var(--danger); }
.error-card pre { background: var(--bg); padding: 1rem; border-radius: 6px; font-size: 0.78rem; color: var(--danger); margin: 0.875rem 0; white-space: pre-wrap; }

/* ── Footer ── */
.footer { text-align: center; padding: 1.25rem; font-size: 0.72rem; color: var(--text3); border-top: 1px solid var(--border); }

/* ── Visibility helpers ── */
.hidden { display: none !important; }

@media (max-width: 640px) {
  .desktop-only { display: none !important; }
}

@media (min-width: 641px) {
  .mobile-only { display: none !important; }
  .mobile-hide { display: block; }
}

@media (max-width: 640px) {
  .mobile-hide { display: none; }
  .main { padding: 0 0.875rem; margin: 1rem auto; gap: 0.875rem; }
  .card { padding: 1.25rem; }
  .upload-zone { padding: 2rem 1rem; }
  .upload-icon { font-size: 2rem; }
  .result-header { flex-direction: column; }
  .result-actions { width: 100%; justify-content: flex-start; }
  .capabilities-grid { grid-template-columns: 1fr; }
  .log-box { height: 200px; }
  .qr-inner { flex-direction: column; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}
