:root {
  color-scheme: light;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0a1628;
  --muted: #64748b;
  --sea-950: #0a1628;
  --sea-800: #0f3d4a;
  --sea-600: #059669;
  --sea-100: #d1fae5;
  --danger: #dc2626;
  --warn: #d97706;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

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

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

body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  min-height: 100dvh;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { border: none; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: max(12px, var(--safe-t)) 16px 12px;
  background: linear-gradient(165deg, var(--sea-950), var(--sea-800));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-title {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.topbar-sub {
  font-size: 0.75rem;
  color: var(--sea-100);
  opacity: 0.9;
}

.status-pill {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.15);
  white-space: nowrap;
}

.status-pill.ok { background: rgba(5, 150, 105, 0.35); }
.status-pill.warn { background: rgba(217, 119, 6, 0.35); }

.screen {
  display: none;
  flex: 1;
  padding: 16px;
  animation: fadeIn 0.25s ease;
}

.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.hero-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(10, 22, 40, 0.06);
  margin-bottom: 16px;
}

.shield-ring {
  width: 120px;
  height: 120px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--sea-600) var(--shield-pct, 100%), #e2e8f0 0);
  position: relative;
}

.shield-ring::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--surface);
}

.shield-ring svg {
  position: relative;
  z-index: 1;
  width: 48px;
  height: 48px;
  color: var(--sea-600);
}

.hero-card h2 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.hero-card p {
  font-size: 0.875rem;
  color: var(--muted);
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  margin-top: 16px;
  padding: 12px 20px;
  border-radius: 14px;
  background: var(--sea-600);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 8px 20px rgba(5, 150, 105, 0.28);
}

.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; pointer-events: none; }

.btn-ghost {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  border-radius: 12px;
  font-weight: 600;
  color: var(--sea-800);
  background: var(--sea-100);
}

.card {
  background: var(--surface);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 12px rgba(10, 22, 40, 0.04);
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-row + .card-row { margin-top: 12px; padding-top: 12px; border-top: 1px solid #e2e8f0; }

.card-label { font-size: 0.9375rem; font-weight: 600; }
.card-meta { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

.toggle {
  width: 48px;
  height: 28px;
  border-radius: 100px;
  background: #cbd5e1;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}

.toggle.on { background: var(--sea-600); }

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s;
}

.toggle.on::after { transform: translateX(20px); }

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 8px 0 10px 4px;
}

.scan-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 22, 40, 0.92);
  color: #fff;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.scan-overlay.open { display: flex; }

.scan-spinner {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--sea-400, #34d399);
  animation: spin 0.9s linear infinite;
  margin-bottom: 12px;
  position: relative;
}

.scan-spinner.done {
  animation: none;
  border-color: var(--sea-600);
  background: var(--sea-600);
}

.scan-spinner.done::after {
  content: "";
  position: absolute;
  inset: 28px;
  border: solid #fff;
  border-width: 0 0 3px 3px;
  transform: rotate(-45deg);
  margin-top: -4px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.scan-pct {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.scan-phase {
  font-size: 0.8125rem;
  color: var(--sea-100);
  margin-top: 10px;
  min-height: 1.2em;
}

.shield-ring.protected svg { color: var(--sea-600); }

.shield-ring.pulse-once {
  animation: shieldPulse 0.7s ease;
}

@keyframes shieldPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.result-time {
  margin: 0 4px 10px;
  text-align: left;
}

.btn-mini {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--muted);
  flex-shrink: 0;
  max-width: 38%;
  line-height: 1.2;
}

.btn-mini.danger {
  background: #fee2e2;
  color: var(--danger);
}

.scan-file {
  font-size: 0.8125rem;
  color: var(--sea-100);
  min-height: 1.4em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  width: 100%;
  max-width: 280px;
  height: 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 100px;
  margin: 16px 0 8px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--sea-600), #34d399);
  border-radius: 100px;
  transition: width 0.15s ease;
}

.result-banner {
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.result-banner.ok { background: var(--sea-100); color: var(--sea-800); }
.result-banner.fix { background: #fef3c7; color: #92400e; }

.list-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}

.list-item:last-child { border-bottom: none; }

.list-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--sea-100);
  color: var(--sea-600);
  flex-shrink: 0;
}

.list-icon.danger { background: #fee2e2; color: var(--danger); }
.list-icon.ok { background: var(--sea-100); color: var(--sea-600); }

.list-body { flex: 1; min-width: 0; }
.list-title { font-weight: 600; font-size: 0.9375rem; }
.list-sub { font-size: 0.75rem; color: var(--muted); }

.badge {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  background: #e2e8f0;
  color: var(--muted);
}

.badge.safe { background: var(--sea-100); color: var(--sea-800); }
.badge.risk { background: #fee2e2; color: var(--danger); }

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  max-width: 480px;
  margin: 0 auto;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid #e2e8f0;
  display: flex;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--muted);
  min-height: var(--nav-h);
}

.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--sea-600); }

.lang-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.lang-chip {
  flex: 1;
  min-height: 40px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.8125rem;
  background: #f1f5f9;
  color: var(--muted);
}

.lang-chip.active {
  background: var(--sea-600);
  color: #fff;
}

.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 0.875rem;
}

.empty svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: 0.4; }

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sea-600);
  box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.5);
  animation: livePulse 1.8s ease infinite;
}

.live-dot--lg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(5, 150, 105, 0); }
  100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

.rt-panel {
  border: 1px solid var(--sea-100);
  background: linear-gradient(180deg, #fff 0%, #f0fdf4 100%);
  margin-bottom: 16px;
}

.rt-panel-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.rt-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--sea-100);
}

.rt-stats div {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.rt-stats strong {
  display: block;
  font-size: 1.25rem;
  color: var(--sea-800);
  margin-bottom: 2px;
}

.log-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
  align-items: flex-start;
}

.log-item:last-child { border-bottom: none; }

.log-time {
  font-size: 0.6875rem;
  color: var(--muted);
  flex-shrink: 0;
  width: 42px;
  padding-top: 2px;
}

.log-body { flex: 1; min-width: 0; }
.log-title { font-size: 0.8125rem; font-weight: 600; line-height: 1.3; }
.log-sub {
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-badge {
  font-size: 0.625rem;
  font-weight: 700;
  padding: 4px 6px;
  border-radius: 6px;
  flex-shrink: 0;
}

.log-badge.block { background: #fee2e2; color: var(--danger); }
.log-badge.ok { background: var(--sea-100); color: var(--sea-800); }

.rt-toast {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: 16px;
  right: 16px;
  max-width: 448px;
  margin: 0 auto;
  z-index: 90;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(10, 22, 40, 0.18);
  border-left: 4px solid var(--sea-600);
  transform: translateY(-120%);
  transition: transform 0.35s ease;
}

.rt-toast.show { transform: translateY(0); }

.rt-toast-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--sea-100);
  color: var(--sea-600);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.rt-toast-icon svg { width: 20px; height: 20px; }

.rt-toast-title { font-size: 0.875rem; font-weight: 700; }
.rt-toast-sub { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
