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

:root {
  --black: #000000;
  --nav-h: 52px;
  --footer-h: 36px;
  --bg: #ffffff;
  --bg-subtle: #f7f7f7;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #666666;
  --accent: #3182ce;
  --danger: #e53e3e;
  --warn-bg: #fffbeb;
  --warn-border: #f6c344;
  --warn-text: #92400e;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --radius: 4px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --bg-subtle: #242424;
    --border: #333333;
    --text: #e8e8e8;
    --text-muted: #999999;
  }
}

body {
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--footer-h);
}

/* ---- NAV ---- */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  background: var(--black);
  padding: 0 12px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--nav-h);
}

.nav-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; order: 1; }
.nav-form-row { display: flex; align-items: center; flex: 1; order: 2; padding: 0 12px; min-width: 0; }
.nav-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; order: 3; }

/* Mobile: logo+buttons on row 1, form full-width on row 2 */
@media (max-width: 600px) {
  .nav-left { order: 1; }
  .nav-right { order: 2; margin-left: auto; }
  .nav-form-row { order: 3; flex: 0 0 100%; padding: 0 0 8px 0; }
}


.nav-url-form { width: 100%; max-width: 600px; }
.nav-logo { display: flex; align-items: center; flex-shrink: 0; }
.nav-logo-img { height: 26px; width: auto; display: block; }
.nav-logo-img--dark { display: none; }
html[data-theme="dark"] .nav-logo-img--light { display: none; }
html[data-theme="dark"] .nav-logo-img--dark { display: block; }
html[data-theme="light"] .nav-logo-img--light { display: block; }
html[data-theme="light"] .nav-logo-img--dark { display: none; }
@media (prefers-color-scheme: dark) {
  .nav-logo-img--light { display: none; }
  .nav-logo-img--dark { display: block; }
}


/* ---- FOOTER ---- */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-h);
  background: #f1f1f1;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #777;
  z-index: 99;
}

@media (prefers-color-scheme: dark) {
  .site-footer { background: #222; }
}

/* ---- MAIN ---- */
.main-content { flex: 1; }

/* ---- INPUT GROUP ---- */
.input-group {
  display: flex;
  align-items: center;
  border: 1px solid #555;
  border-radius: var(--radius);
  overflow: hidden;
}

.input-group--sm { border-color: #444; }

.url-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 8px 10px;
  font-size: 14px;
  font-family: var(--mono);
  background: transparent;
  color: var(--text);
  min-width: 0;
}

.url-input--nav { color: #fff; background: transparent; }
.url-input--nav::placeholder { color: #888; }

.url-submit {
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-left: 1px solid #555;
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.url-submit:hover { background: rgba(255,255,255,0.1); }
.url-input--nav ~ .url-submit { color: #fff; }
.url-submit--sm { padding: 6px 12px; }

.scheme-toggle {
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-right: 1px solid #555;
  color: #888;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--mono);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s;
  user-select: none;
}
.scheme-toggle:hover { color: var(--text); }
.scheme-toggle--https { color: #4caf50; }
.scheme-toggle--sm { padding: 6px 8px; font-size: 11px; }
.url-form .scheme-toggle { border-right-color: var(--border); }
.scheme-toggle[hidden] { display: none; }

.form-error { color: var(--danger); font-size: 13px; margin-top: 6px; text-align: center; }

/* ---- SPLASH ---- */
.splash {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}

.splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 900px;
  padding: 0 16px;
}

.splash-logo { width: 80%; height: auto; }

.splash-logo--dark { display: none; }
@media (prefers-color-scheme: dark) {
  .splash-logo--light { display: none; }
  .splash-logo--dark { display: block; }
}
html[data-theme="dark"] .splash-logo--light { display: none; }
html[data-theme="dark"] .splash-logo--dark { display: block; }
html[data-theme="light"] .splash-logo--light { display: block; }
html[data-theme="light"] .splash-logo--dark { display: none; }

.url-form { width: 100%; }
.url-form .input-group { border-color: var(--border); border-width: 2px; border-radius: 8px; }
.url-form .url-input { color: var(--text); font-size: 18px; padding: 13px 14px; }
.url-form .url-submit { border-left-color: var(--border); color: var(--text); font-size: 20px; padding: 11px 18px; }
.url-form .scheme-toggle { font-size: 13px; padding: 11px 11px; }

.splash-desc {
  font-size: 15px;
  text-align: center;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 380px;
}

/* ---- RESULTS COLUMNS ---- */
.results-columns {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.col-left { width: 40%; border-right: 1px solid var(--border); }
.col-right { width: 60%; }

@media (max-width: 768px) {
  .results-columns { flex-direction: column; }
  .col-left, .col-right { width: 100%; border-right: none; }
}

/* ---- DOMAIN BOX ---- */
.domain-box { padding: 12px; display: flex; flex-direction: column; gap: 6px; }

.data-row {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.data-label {
  padding: 6px 10px;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  font-size: 12px;
  white-space: nowrap;
  min-width: 9em;
  color: var(--text-muted);
}

.data-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 6px 8px;
  font-size: 12px;
  font-family: var(--mono);
  background: transparent;
  color: var(--text);
  min-width: 0;
}

.copy-btn {
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  transition: background 0.15s;
  flex-shrink: 0;
}
.copy-btn:hover { background: var(--bg-subtle); }
.copy-btn.copied { color: green; }

/* ---- ACCORDION ---- */
.accordion { border-top: 1px solid var(--border); }

.accordion-item { border-bottom: 1px solid var(--border); }

.accordion-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  transition: background 0.15s;
}
.accordion-btn:hover { background: var(--bg-subtle); }

.accordion-icon { font-size: 12px; transition: transform 0.2s; }
.accordion-btn[aria-expanded="true"] .accordion-icon { transform: rotate(180deg); }

.accordion-panel { padding: 8px 0; }

/* ---- CERT TABLE ---- */
.cert-box { padding: 12px; }
.cert-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.cert-table th { text-align: left; font-weight: 600; padding: 6px 8px; font-size: 13px; }
.cert-table td { padding: 3px 8px; vertical-align: top; }
.cert-key { color: var(--text-muted); white-space: nowrap; font-weight: 500; }
.cert-val { font-family: var(--mono); word-break: break-all; }

/* ---- HTTP HEADERS ---- */
.hop-block { padding: 8px 16px; border-bottom: 1px solid var(--border); }
.hop-block:last-child { border-bottom: none; }

.hop-title { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; font-size: 15px; font-weight: 600; flex-wrap: wrap; }

.status-code {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: var(--radius);
}

.hop-url { font-family: var(--mono); font-size: 12px; color: var(--text-muted); word-break: break-all; }

.header-row { display: flex; gap: 8px; padding: 2px 0; flex-wrap: wrap; }
.header-name { font-size: 12px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.header-val { font-size: 12px; font-family: var(--mono); color: var(--text-muted); word-break: break-all; }

/* ---- SCREENSHOT ---- */
.screenshot-box { width: 100%; }
.screenshot-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 24px;
}
.screenshot-img { width: 100%; display: block; }

/* ---- SPINNER ---- */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner--sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- TABS ---- */
.tabs-section {
  border-top: 1px solid var(--border);
  min-height: 300px;
}

.tab-list {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.tab-btn {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn--active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }

.tab-panel { padding: 16px; }
#tab-source { padding: 0; }

/* ---- SOURCE SPLIT ---- */
.source-split {
  display: flex;
  height: 560px;
}
.source-split__code {
  flex: 0 0 50%;
  min-width: 0;
  overflow: auto;
  padding: 16px;
  border-right: 1px solid var(--border);
  box-sizing: border-box;
}
.source-split__signals {
  flex: 0 0 50%;
  min-width: 0;
  overflow-y: auto;
  padding: 12px;
  box-sizing: border-box;
}

/* ---- SOURCE ---- */
.source-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.content-type-label { font-size: 12px; color: var(--text-muted); }
.content-type-label code { font-family: var(--mono); }

#source-pre {
  overflow-x: auto;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.5;
  padding: 12px;
}
#source-pre code {
  font-family: var(--mono);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---- RESOURCES TOOLBAR ---- */
.resource-section-header { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.resource-section-title { font-size: 14px; font-weight: 600; margin: 0; }
.resource-toolbar { display: flex; align-items: center; gap: 8px; }
.resource-filter {
  padding: 4px 8px; font-size: 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text);
  width: 180px;
}
.resource-filter:focus { outline: none; border-color: var(--accent); }

/* ---- RESOURCES TABLE ---- */
.resource-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 24px;
}
.resource-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
}
.resource-table td { padding: 6px 12px; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 12px; word-break: break-all; }
.resource-table tr:last-child td { border-bottom: none; }
.resource-table td:first-child,
.resource-table th:first-child { width: 1%; white-space: nowrap; }
.resource-section-title { font-size: 15px; font-weight: 600; margin: 16px 0 8px; }

/* ---- LOADING ROW ---- */
.loading-row { display: flex; align-items: center; gap: 10px; padding: 20px 0; color: var(--text-muted); }
.loading-row[hidden] { display: none; }

/* ---- BUTTONS ---- */
.btn-outline {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.btn-outline:hover { border-color: var(--accent); background: var(--bg-subtle); }

.btn-blue {
  padding: 7px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-blue:hover { opacity: 0.88; }

/* ---- TAGS ---- */
.tag { font-size: 12px; padding: 2px 8px; border-radius: 12px; font-weight: 500; }
.tag--warn { background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-border); }

.muted-text { color: var(--text-muted); font-size: 13px; padding: 12px 0; }

/* ---- DARK MODE OVERRIDE (JS-toggled via data-theme on <html>) ---- */
html[data-theme="dark"] {
  --bg: #1a1a1a;
  --bg-subtle: #242424;
  --border: #333333;
  --text: #e8e8e8;
  --text-muted: #999999;
}
html[data-theme="light"] {
  --bg: #ffffff;
  --bg-subtle: #f7f7f7;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #666666;
}
html[data-theme="dark"] .site-footer { background: #222; }
html[data-theme="light"] .site-footer { background: #f1f1f1; }

/* ---- NAV BUTTONS ---- */
.nav-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid #555;
  border-radius: var(--radius);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.nav-btn:hover { background: #222; }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--bg);
  border-radius: 8px;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.modal--wide { max-width: 680px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 8px;
}
.modal-header h2 { font-size: 20px; font-weight: 700; }

.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

.modal-subtitle {
  padding: 0 20px 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.modal-body { padding: 0 20px 16px; flex: 1; overflow-y: auto; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

.modal-section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
}

/* ---- DARK MODE TOGGLE ---- */
.toggle-label { display: flex; align-items: center; cursor: pointer; }
.toggle-track {
  width: 44px; height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
}
input[type="checkbox"]:checked + .toggle-track { background: var(--accent); }
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.2s;
}
input[type="checkbox"]:checked + .toggle-track .toggle-thumb { left: 23px; }
input[type="checkbox"][role="switch"] { display: none; }

/* ---- CUSTOM SERVICES FORM ---- */
.csf-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}
.csf-field { display: flex; flex-direction: column; gap: 4px; }
.csf-field--flex { flex: 1; min-width: 160px; }
.csf-select, .csf-input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.csf-select:focus, .csf-input:focus { border-color: var(--accent); }
.csf-helper { font-size: 11px; color: var(--text-muted); }

/* ---- CUSTOM SERVICES LIST ---- */
.cs-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.cs-item:last-child { border-bottom: none; }
.cs-item input { padding: 4px 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); font-size: 12px; }
.cs-type-input { width: 5em; }
.cs-name-input { width: 7em; }
.cs-url-input { flex: 1; min-width: 120px; }
.cs-delete {
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--danger);
  font-size: 13px;
  flex-shrink: 0;
}
.cs-delete:hover { background: #fee2e2; }

/* ---- WHAT MODAL ---- */
.what-lead { font-size: 15px; margin-bottom: 12px; font-weight: 500; }
.what-body h3 { font-size: 15px; font-weight: 700; margin: 14px 0 4px; }
.what-body p { font-size: 13px; color: var(--text-muted); line-height: 1.6; padding-left: 8px; }
.what-body code { font-family: var(--mono); font-size: 12px; background: var(--bg-subtle); padding: 1px 4px; border-radius: 3px; }

/* ---- PIVOT BUTTONS ---- */
.data-actions {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
}

.pivot-wrap {
  position: relative;
}

.pivot-btn {
  height: 100%;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background 0.15s;
}
.pivot-btn:hover { background: var(--bg-subtle); color: var(--text); }

.pivot-menu[hidden] { display: none; }
.pivot-menu {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 300;
  min-width: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  padding: 4px 0;
}

.pivot-menu-header {
  padding: 5px 12px 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pivot-indicator {
  padding: 3px 12px 6px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  word-break: break-all;
}

.pivot-menu a {
  display: block;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pivot-menu a:hover { background: var(--bg-subtle); }

.pivot-empty {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- SIGNAL FLAGS ---- */
.sig-flag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.sig-flag--warn { background: #fff3cd; color: #7a5c00; }
.sig-flag--danger { background: #fde8e8; color: #a00; }
html[data-theme="dark"] .sig-flag--warn { background: #4a3800; color: #ffd55a; }
html[data-theme="dark"] .sig-flag--danger { background: #4a0000; color: #ff7070; }

/* ---- SCREENSHOT SKELETON ---- */
@keyframes skel-pulse {
  0%   { opacity: 0.55; }
  50%  { opacity: 0.08; }
  100% { opacity: 0.55; }
}

.skel-svg {
  display: block;
  width: 100%;
  height: auto;
  background: #c8c8c8;
  will-change: opacity;
  animation-name: skel-pulse;
  animation-duration: 1.4s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

/* ---- SIGNAL FLAGS ---- */
.sig-flag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.sig-flag--warn { background: #fff3cd; color: #7a5c00; }
.sig-flag--danger { background: #fde8e8; color: #a00; }
html[data-theme="dark"] .sig-flag--warn { background: #4a3800; color: #ffd55a; }
html[data-theme="dark"] .sig-flag--danger { background: #4a0000; color: #ff7070; }

/* ---- SCREENSHOT SKELETON ---- */
@keyframes skel-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skel-b {
  background: linear-gradient(90deg,
    #d8d8d8 25%,
    #ebebeb 50%,
    #d8d8d8 75%
  );
  background-size: 200% 100%;
  animation: skel-shimmer 1.6s ease-in-out infinite;
  border-radius: 3px;
}
html[data-theme="dark"] .skel-b { background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%); background-size: 200% 100%; }
@media (prefers-color-scheme: dark) { .skel-b { background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%); background-size: 200% 100%; } }

.skel-screenshot {
  width: 100%;
  min-height: 320px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 0;
}
