:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --green: #3fb950;
  --orange: #d29922;
  --red: #f85149;
  --radius: 8px;
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --border: #d0d7de;
  --text: #1f2328;
  --text-muted: #656d76;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --green: #1a7f37;
  --orange: #9a6700;
  --red: #cf222e;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header .header-left { text-align: left; }
header h1 { font-size: 1.3rem; }
header h1 a { color: var(--text); text-decoration: none; }
header .subtitle { color: var(--text-muted); font-size: 0.85rem; }
.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 0;
  width: 52px;
  height: 28px;
  cursor: pointer;
  position: relative;
  transition: background 0.3s, border-color 0.3s;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-icon {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--orange);
  transition: transform 0.3s, background 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-icon::after {
  content: "\2600";
  font-size: 12px;
  line-height: 1;
}
[data-theme="light"] .theme-icon {
  transform: translateX(24px);
  background: var(--accent);
}
[data-theme="light"] .theme-icon::after {
  content: "\263E";
}

main { max-width: 100%; margin: 0; padding: 1.25rem 2rem; }
footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}
footer code { background: var(--surface); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.75rem; }

/* Stats */
.stats { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  flex: 1;
  min-width: 130px;
  text-align: center;
}
.stat-card .number { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.stat-card .label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* Filters */
.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.filters h2 { font-size: 0.9rem; margin-bottom: 0.6rem; }
.filter-row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.filter-group { flex: 1; min-width: 150px; }
.filter-group label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}
.filter-group select,
.filter-group input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
}
.filter-group select:focus,
.filter-group input:focus { outline: none; border-color: var(--accent); }
.filter-actions { display: flex; gap: 0.5rem; align-items: flex-end; }
.btn {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }

/* Active filter chips */
.active-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  background: rgba(88, 166, 255, 0.1);
  border: 1px solid rgba(88, 166, 255, 0.3);
  border-radius: 12px;
  font-size: 0.7rem;
  color: var(--accent);
}
.filter-chip button {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: 0.85rem; line-height: 1; padding: 0; margin-left: 0.1rem;
}
.filter-chip button:hover { color: var(--red); }
.filter-chip-clear {
  background: none; border: 1px solid var(--border); border-radius: 12px;
  padding: 0.2rem 0.6rem; color: var(--text-muted); cursor: pointer; font-size: 0.7rem;
}
.filter-chip-clear:hover { color: var(--red); border-color: var(--red); }

.result-count { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 0.75rem; }

.build-date { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; }
.badge-os { background: rgba(139, 148, 158, 0.15); color: var(--text-muted); }

/* Table */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
thead { background: var(--surface); position: sticky; top: 0; z-index: 10; }
th {
  padding: 0.6rem 0.5rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th:hover { color: var(--accent); }
th .sort-arrow { margin-left: 0.15rem; font-size: 0.55rem; }
td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
tr:hover td { background: rgba(88, 166, 255, 0.05); }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-api { background: rgba(88, 166, 255, 0.15); color: var(--accent); }
.badge-abi { background: rgba(63, 185, 80, 0.15); color: var(--green); }
.badge-channel { background: rgba(210, 153, 34, 0.15); color: var(--orange); }
.badge-stable { background: rgba(63, 185, 80, 0.15); color: var(--green); }
.badge-canary { background: rgba(248, 81, 73, 0.15); color: var(--red); }
.badge-dev { background: rgba(210, 153, 34, 0.15); color: var(--orange); }
.badge-eol-active { background: rgba(63, 185, 80, 0.15); color: var(--green); }
.badge-eol-eol { background: rgba(248, 81, 73, 0.15); color: var(--red); }

/* CVE severity badges */
.badge-severity-critical { background: rgba(248, 81, 73, 0.2); color: var(--red); }
.badge-severity-high { background: rgba(210, 153, 34, 0.2); color: var(--orange); }
.badge-severity-medium { background: rgba(139, 148, 158, 0.15); color: var(--text-muted); }
.badge-severity-low { background: rgba(139, 148, 158, 0.1); color: var(--text-muted); }

/* CVE type badges */
.badge-type-rce { background: rgba(248, 81, 73, 0.15); color: var(--red); }
.badge-type-eop { background: rgba(210, 153, 34, 0.15); color: var(--orange); }
.badge-type-id { background: rgba(88, 166, 255, 0.15); color: var(--accent); }
.badge-type-dos { background: rgba(139, 148, 158, 0.15); color: var(--text-muted); }

/* CVE page */
.cve-id { background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.7rem; }

/* Emulator testable toggle */
.emu-filter-group { min-width: 250px; }
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  user-select: none;
}
.toggle-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}
.filter-hint {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  line-height: 1.3;
}
.filter-chip-emu { background: rgba(63, 185, 80, 0.1); border-color: rgba(63, 185, 80, 0.3); color: var(--green); }
.badge-emu-yes { background: rgba(63, 185, 80, 0.15); color: var(--green); }
.badge-emu-partial { background: rgba(210, 153, 34, 0.15); color: var(--orange); }
.badge-emu-no { background: rgba(139, 148, 158, 0.1); color: var(--text-muted); }
.detail-muted { color: var(--text-muted); font-size: 0.85em; }
.badge-exploit-poc { background: rgba(210, 153, 34, 0.15); color: var(--orange); }
.badge-exploit-full { background: rgba(248, 81, 73, 0.15); color: var(--red); }
.filter-chip-exploit { background: rgba(210, 153, 34, 0.15) !important; border-color: var(--orange) !important; }
.exploit-link {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  margin: 0.15rem;
  font-size: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  text-decoration: none;
  font-family: monospace;
}
.exploit-link:hover { border-color: var(--accent); background: rgba(88, 166, 255, 0.08); }
.exploit-link-best { border-color: var(--orange); background: rgba(210, 153, 34, 0.1); }
.exploit-link-best:hover { border-color: var(--orange); background: rgba(210, 153, 34, 0.18); }
.exploit-stars { margin-left: 0.3rem; color: var(--orange); font-size: 0.7rem; }
.exploit-stars-zero { color: var(--text-muted); }
.exploit-warn { margin-left: 0.2rem; color: var(--red); font-size: 0.7rem; cursor: help; }
.repo-type { display: inline-block; padding: 0 0.25rem; font-size: 0.6rem; font-weight: 700; border-radius: 2px; margin-left: 0.2rem; }
.repo-type-trigger { background: rgba(63, 185, 80, 0.2); color: var(--green); }
.repo-type-writeup { background: rgba(210, 153, 34, 0.2); color: var(--orange); }
.repo-type-unknown { background: rgba(139, 148, 158, 0.2); color: var(--text-muted); }
.repo-files-toggle { font-size: 0.7rem; color: var(--accent); cursor: pointer; user-select: none; margin-left: 0.4rem; }
.repo-files-toggle:hover { text-decoration: underline; }
.repo-files-detail { width: 100%; margin: 0.2rem 0; }
.repo-files-summary { font-size: 0.7rem; color: var(--accent); cursor: pointer; list-style: none; }
.repo-files-summary::-webkit-details-marker { display: none; }
.repo-files-list { margin: 0.25rem 0 0 1.2rem; padding: 0; list-style: none; font-size: 0.7rem; display: flex; flex-direction: column; gap: 0.15rem; }
.repo-files-list li { line-height: 1.4; }
.repo-files-list code { font-size: 0.7rem; word-break: break-all; }
.repo-files-list .confidence { color: var(--text-muted); margin-left: 0.4rem; font-size: 0.65rem; }
.repo-files-list .via-bug { color: var(--text-muted); font-style: italic; margin-right: 0.3rem; }
.repo-source-discovered { font-size: 0.7rem; opacity: 0.6; margin-left: 0.2rem; cursor: help; }
.repo-source-nickname { font-size: 0.6rem; padding: 0 0.3rem; background: rgba(210, 153, 34, 0.15); color: var(--orange); border-radius: 3px; margin-left: 0.2rem; cursor: help; font-weight: 600; }
.exploit-link-warn { border-color: rgba(248, 81, 73, 0.3); opacity: 0.75; }
.exploit-link-warn:hover { border-color: var(--red); opacity: 1; }
.exploit-repos-list { display: flex; flex-wrap: wrap; gap: 0.25rem; }

/* ABI architecture guide */
.abi-guide {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.abi-guide summary {
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
  user-select: none;
  list-style: none;
}
.abi-guide summary::before {
  content: "\25B6";
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 0.65rem;
  transition: transform 0.2s;
}
.abi-guide[open] summary::before { transform: rotate(90deg); }
.abi-guide summary:hover { color: var(--accent-hover); }
.abi-guide-content { padding: 0 1.25rem 1.25rem; }
.abi-guide-content .info-grid { margin-bottom: 1rem; }
.abi-guide-content .info-card h3 { font-size: 0.9rem; margin-bottom: 0.3rem; }
.abi-guide-content .info-card p { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.abi-cross-table { margin-top: 0.5rem; }
.abi-cross-table h3 { font-size: 0.9rem; margin-bottom: 0.5rem; }
.abi-warning {
  margin-top: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: rgba(248, 81, 73, 0.08);
  border-left: 3px solid var(--red);
  border-radius: 0 4px 4px 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.pagination-info { color: var(--text-muted); font-size: 0.8rem; }
.pagination-buttons { display: flex; gap: 0.3rem; align-items: center; flex-wrap: wrap; }
.pagination-buttons .btn { padding: 0.3rem 0.6rem; font-size: 0.75rem; min-width: 2rem; text-align: center; }
.pagination-buttons .btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }
.pagination-active { background: var(--accent) !important; color: var(--bg) !important; border-color: var(--accent) !important; }
.pagination-ellipsis { color: var(--text-muted); font-size: 0.8rem; padding: 0 0.2rem; }

.dl-link { color: var(--accent); text-decoration: none; font-weight: 500; font-size: 0.75rem; }
.dl-link:hover { text-decoration: underline; color: var(--accent-hover); }

.fingerprint-cell {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 0.65rem;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Download button in table */
.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  background: rgba(88, 166, 255, 0.1);
  border: 1px solid rgba(88, 166, 255, 0.3);
  border-radius: 5px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}
.dl-btn:hover { background: rgba(88, 166, 255, 0.2); border-color: var(--accent); text-decoration: none; }
.dl-btn svg { width: 12px; height: 12px; fill: currentColor; }

/* Detail modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 750px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h2 { margin-bottom: 1rem; font-size: 1rem; }
.modal .close-btn {
  float: right;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.modal .close-btn:hover { color: var(--text); }
.detail-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.3rem 1rem;
  font-size: 0.8rem;
}
.detail-grid dt { color: var(--text-muted); font-weight: 600; }
.detail-grid dd { word-break: break-all; }
.detail-grid dt.section-header {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  margin: 0.6rem 0 0.2rem;
  padding-top: 0.6rem;
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.detail-grid dd code {
  background: var(--bg);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.75rem;
  word-break: break-all;
}

/* About page */
.about-page { max-width: 1000px; margin: 0 auto; }
.about-page h2 {
  font-size: 1.15rem;
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
}
.about-page h2:first-child { margin-top: 0; }
.about-page p { color: var(--text-muted); margin-bottom: 0.75rem; line-height: 1.7; font-size: 0.9rem; }
.about-page ul { color: var(--text-muted); margin: 0.5rem 0 1rem 1.5rem; font-size: 0.9rem; line-height: 1.8; }
.about-page code { background: var(--surface); border: 1px solid var(--border); padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.8rem; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0; }
.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.info-card h3 { font-size: 0.95rem; margin-bottom: 0.5rem; }
.info-card p { font-size: 0.85rem; }
.info-card ul { font-size: 0.85rem; line-height: 1.7; }
.info-table { font-size: 0.8rem; }
.info-table th { font-size: 0.7rem; }
.info-table td { white-space: normal; line-height: 1.5; }

/* Nav */
.nav-links { display: flex; gap: 1rem; margin-right: 1rem; }
.nav-links a { color: var(--text-muted); text-decoration: none; font-size: 0.85rem; font-weight: 500; }
.nav-links a:hover, .nav-links a.active { color: var(--accent); }

.header-right { display: flex; align-items: center; }

/* References + AOSP patches (CVE detail modal) */
.ref-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.ref-list li { font-size: 0.8rem; line-height: 1.5; }
.ref-secondary { color: var(--text-muted); font-size: 0.75rem; font-style: italic; margin-right: 0.25rem; }
.ext-ref-note { color: var(--text-muted); font-size: 0.7rem; }

.aosp-help { font-size: 0.75rem; color: var(--text-muted); line-height: 1.5; }
.aosp-patch { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.5rem 0.65rem; background: rgba(88, 166, 255, 0.04); border-left: 2px solid var(--accent); border-radius: 3px; }
.aosp-row { font-size: 0.75rem; line-height: 1.5; word-break: break-all; }
.aosp-key { color: var(--text-muted); display: inline-block; min-width: 3.5rem; font-weight: 500; }
.aosp-sha { color: var(--orange); }
.aosp-cmd { display: inline-block; background: rgba(0, 0, 0, 0.25); padding: 0.15rem 0.4rem; border-radius: 3px; user-select: all; }
.aosp-subject { font-size: 0.85rem; font-weight: 500; color: var(--text); margin-bottom: 0.2rem; line-height: 1.35; }
.aosp-meta { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.aosp-files { margin-top: 0.3rem; font-size: 0.7rem; }
.aosp-files summary { cursor: pointer; color: var(--accent); user-select: none; }
.aosp-files summary:hover { text-decoration: underline; }
.aosp-files ul { margin: 0.3rem 0 0; padding-left: 1rem; list-style: none; display: flex; flex-direction: column; gap: 0.15rem; }
.aosp-files code { font-size: 0.7rem; }
.file-op { display: inline-block; width: 1.1rem; text-align: center; font-weight: 700; font-size: 0.65rem; padding: 0.05rem 0; border-radius: 2px; margin-right: 0.3rem; }
.file-op-add, .file-op-A { background: rgba(63, 185, 80, 0.2); color: var(--green); }
.file-op-modify, .file-op-M { background: rgba(88, 166, 255, 0.2); color: var(--accent); }
.file-op-delete, .file-op-D { background: rgba(248, 81, 73, 0.2); color: var(--red); }
.file-op-rename, .file-op-R { background: rgba(210, 153, 34, 0.2); color: var(--orange); }

@media (max-width: 768px) {
  .info-grid { grid-template-columns: 1fr; }
  header { flex-direction: column; gap: 0.5rem; text-align: center; }
  .filter-row { flex-direction: column; }
  .filter-group { min-width: 100%; }
  .stats { flex-direction: column; }
  th, td { padding: 0.3rem 0.4rem; font-size: 0.7rem; }
}
