/* ===========================================================================
   Lovense DPI Checker — re-skinned to the OBFSN extension design system:
   dark, flat, dense; hairline borders instead of shadows; accent blue.
   Tokens copied verbatim from the OBFSN extension (src/popup/style.css).
   =========================================================================== */

:root {
  --font: "Google Sans Flex", "Google Sans", "Google Sans Text", system-ui, -apple-system, sans-serif;

  --bg: #14181e;
  --bg2: #1c2128;
  --bg3: #242b35;
  --surface: #1c2128;
  --surface-2: #242b35;
  --surface-3: #2b333f;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text: #e8e8e8;
  --text-muted: #8a8f99;
  --text-faint: #6b7280;

  --accent: #4f8ef7;
  --accent-hover: #6ba0f8;
  --accent-weak: rgba(79, 142, 247, 0.16);
  --danger: #ff5a5a;
  --danger-hover: #ff7676;
  --danger-weak: rgba(240, 106, 106, 0.1);
  --ok: #3ecf64;
  --ok-weak: rgba(62, 207, 100, 0.12);
  --warn: #d4b03a;
  --warn-weak: rgba(212, 176, 58, 0.12);

  --rkn: #b794f6;
  --rkn-weak: rgba(167, 139, 250, 0.16);

  --radius-sm: 6px;
  --radius: 8px;
  --radius-pill: 999px;

  --shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ─── Page head ─────────────────────────────────────────── */
.page-head {
  margin: 0 0 18px;
}

.page-title {
  margin: 0 0 6px;
  font-size: 1.6em;
  font-weight: 700;
  letter-spacing: -.01em;
  color: #f3f5f8;
  /* reset any cached gradient/transparent fill from the old theme */
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: #f3f5f8;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-weak);
}

.page-sub {
  margin: 0;
  max-width: 760px;
  color: var(--text-muted);
  font-size: .98em;
}

.page-sub b {
  color: var(--text);
  font-weight: 600;
}

/* ─── Header / controls ─────────────────────────────────── */
#header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.header-status {
  font-size: 1em;
  color: var(--text-muted);
}

#status {
  font-weight: 600;
  color: var(--text);
}

.status-ready {
  color: var(--ok) !important;
}

.status-checking {
  color: var(--accent) !important;
}

.status-error {
  color: var(--danger) !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

#asn,
#shareTs {
  margin-top: .2em;
  font-size: .88em;
  color: var(--text-muted);
}

/* ─── Card primitive ────────────────────────────────────── */
.products,
.verdict,
.help-panel,
.table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ─── Product cards ─────────────────────────────────────── */
.products {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 16px 0;
  background: var(--border);
  /* gap lines */
  border: 1px solid var(--border);
  overflow: hidden;
}

.product-card {
  background: var(--bg2);
  padding: 14px 16px;
  border-top: 3px solid var(--text-faint);
}

.product-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.product-icon {
  font-size: 1.3em;
  line-height: 1;
}

.product-name {
  font-size: 1.05em;
  font-weight: 700;
}

.product-desc {
  margin: 4px 0 10px;
  font-size: .84em;
  color: var(--text-muted);
}

.product-status {
  font-weight: 700;
  font-size: 1em;
}

.product-ok {
  border-top-color: var(--ok);
}

.product-ok .product-status {
  color: var(--ok);
}

.product-warn {
  border-top-color: var(--warn);
}

.product-warn .product-status {
  color: var(--warn);
}

.product-bad {
  border-top-color: var(--danger);
}

.product-bad .product-status {
  color: var(--danger);
}

.product-na .product-status {
  color: var(--text-muted);
}

/* ─── Verdict ───────────────────────────────────────────── */
.verdict {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin: 16px 0;
  padding: 18px 20px;
  border-left: 3px solid var(--text-faint);
}

.verdict-hidden {
  display: none;
}

.verdict-ok {
  border-left-color: var(--ok);
  background: var(--ok-weak);
}

.verdict-warn {
  border-left-color: var(--warn);
  background: var(--warn-weak);
}

.verdict-bad {
  border-left-color: var(--danger);
  background: var(--danger-weak);
}

.verdict-icon {
  font-size: 2em;
  line-height: 1;
  flex-shrink: 0;
}

.verdict-title {
  margin: 0 0 6px;
  font-size: 1.2em;
  color: var(--text);
}

.verdict-text {
  margin: 0 0 10px;
  color: var(--text);
}

.verdict-details {
  margin: 0;
  padding-left: 1.2em;
  color: var(--text-muted);
  font-size: .95em;
}

.verdict-details code {
  background: rgba(255, 255, 255, .07);
  padding: 0 5px;
  border-radius: var(--radius-sm);
  font-size: .92em;
  color: var(--text);
}

/* ─── Help panel ────────────────────────────────────────── */
.help-panel {
  margin: 14px 0;
  padding: 16px 18px;
}

.help-heading {
  margin: 0 0 12px;
  font-size: 1.05em;
  color: var(--text);
}

.help-subheading {
  margin: 14px 0 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.group-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}

.group-legend-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: .9em;
  color: var(--text-muted);
}

.g-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 600;
  font-size: .84em;
  white-space: nowrap;
}

.tier-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}

.tier-legend-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: .9em;
  line-height: 1.45;
  color: var(--text-muted);
}

.dpi-help {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  --dpi-chevron-size: 0.55em;
  --dpi-chevron-gap: 10px;
}

.dpi-help summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: flex-start;
  gap: var(--dpi-chevron-gap);
  line-height: 1.45;
}

.dpi-help summary::-webkit-details-marker {
  display: none;
}

.dpi-help summary::marker {
  content: "";
}

.dpi-help summary::before {
  content: "";
  flex: 0 0 var(--dpi-chevron-size);
  width: var(--dpi-chevron-size);
  height: var(--dpi-chevron-size);
  margin-top: 0.42em;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transform-origin: 40% 60%;
  transition: transform 0.15s ease;
}

.dpi-help[open] summary::before {
  transform: rotate(45deg);
  margin-top: 0.28em;
}

.dpi-help-body {
  padding-left: calc(var(--dpi-chevron-size) + var(--dpi-chevron-gap));
}

.dpi-help-intro {
  margin: 10px 0 14px;
  line-height: 1.6;
  color: var(--text-muted);
  font-size: .92em;
}

.dpi-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.dpi-card {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg3);
}

.dpi-card-title {
  margin: 0 0 6px;
  font-size: .95em;
  line-height: 1.3;
  color: var(--text);
}

.dpi-card p {
  margin: 0;
  font-size: .86em;
  line-height: 1.5;
  color: var(--text-muted);
}

.dpi-card-bad {
  border-color: rgba(255, 90, 90, .35);
}

.dpi-card-bad .dpi-card-title {
  color: var(--danger);
}

.dpi-card-warn {
  border-color: rgba(212, 176, 58, .35);
}

.dpi-card-warn .dpi-card-title {
  color: var(--warn);
}

.dpi-card-ok {
  border-color: rgba(62, 207, 100, .35);
}

.dpi-card-ok .dpi-card-title {
  color: var(--ok);
}

.dpi-card-muted .dpi-card-title {
  color: var(--text-muted);
}

/* ─── Results table ─────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin-top: .5em;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  background: transparent;
}

th,
td {
  padding: 9px 11px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  vertical-align: middle;
}

th {
  background: var(--bg3);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600 !important;
  letter-spacing: .05em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
}

#results td:nth-child(1),
#results th:nth-child(1) {
  text-align: left;
  white-space: nowrap;
  min-width: 150px;
}

.col-host {
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: .86em;
  color: var(--text);
}

#results th:nth-child(2),
#results td:nth-child(2) {
  text-align: left;
  min-width: 150px;
}

#results th:nth-child(3),
#results td.col-tier {
  min-width: 116px;
  white-space: nowrap;
}

/* tier badges as chips (importance, not status) */
#results td.col-tier {
  font-size: .82em;
  font-weight: 600;
}

#results td.tier-cell-critical {
  color: var(--danger);
}

#results td.tier-cell-important {
  color: var(--warn);
}

#results td.tier-cell-optional {
  color: var(--text-muted);
}

#results td.tier-cell-local,
#results td.tier-cell-meta {
  color: var(--rkn);
}

#results th:nth-child(4),
#results td.col-work {
  min-width: 130px;
}

#results th:nth-child(5),
#results td:nth-child(5),
#results th:nth-child(6),
#results td:nth-child(6) {
  min-width: 104px;
  white-space: nowrap;
}

tbody tr:not(.group-row):hover td {
  background: rgba(255, 255, 255, .03);
}

tr:last-child td {
  border-bottom: 0;
}

/* group separator rows */
.group-row td {
  text-align: left;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
}

.group-row-title {
  display: inline-block;
  font-weight: 700;
  color: var(--text);
  margin-right: 10px;
}

.group-row-sub {
  font-size: .84em;
  color: var(--text-muted);
}

.ok {
  color: var(--ok);
  font-weight: 600;
}

.skip {
  color: var(--text-muted);
}

.bad {
  color: var(--danger);
  font-weight: 600;
}

.work-ok {
  color: var(--ok);
  font-weight: 700;
}

.work-warn {
  color: var(--warn);
  font-weight: 700;
}

.work-fail {
  color: var(--danger);
  font-weight: 700;
}

.work-na {
  color: var(--text-muted);
}

tr[data-tier="critical"] td.col-host {
  border-left: 3px solid var(--danger);
}

tr[data-tier="important"] td.col-host {
  border-left: 3px solid var(--warn);
}

/* ─── Log & footer ──────────────────────────────────────── */
#log {
  background: #0f1318;
  color: #c7ccd6;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: .85em ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace;
  max-height: 300px;
  overflow-y: auto;
  margin: .8em 0;
  overflow-wrap: anywhere;
}

.footer {
  margin-top: 20px;
  font-size: .88em;
  color: var(--text-muted);
}

.footer b {
  color: var(--text);
  font-weight: 600;
}

.asn-br::after {
  content: " • ";
}

.tier-badge {
  display: inline-block;
  padding: 1px 9px;
  border-radius: var(--radius-pill);
  font-size: .82em;
  font-weight: 600;
  white-space: nowrap;
}

.tier-critical {
  background: var(--danger-weak);
  color: var(--danger);
}

.tier-important {
  background: var(--warn-weak);
  color: var(--warn);
}

.tier-optional {
  background: var(--bg3);
  color: var(--text-muted);
}

.tier-local,
.tier-meta {
  background: var(--rkn-weak);
  color: var(--rkn);
}

/* ─── Scrollbars (OBFSN) ────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .18);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, .28);
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 720px) {
  .products {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  body {
    padding: 12px;
  }

  .page-title {
    font-size: 1.35em;
  }

  table {
    font-size: .92em;
  }

  th,
  td {
    padding: 6px 7px;
  }

  .help-panel {
    padding: 12px;
  }

  .group-legend,
  .tier-legend,
  .dpi-cards {
    grid-template-columns: 1fr;
  }

  .verdict {
    flex-direction: column;
    padding: 12px;
  }

  #log {
    padding: 8px;
  }

  .asn-br::after {
    content: "\A";
    white-space: pre;
  }
}
