:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel2: #ffffff;
  --text: #000000;
  --muted: #4b5563;
  --link: #0b63d1;
  --border: #d0d7de;
  --chip: #f6f8fa;
  --chip-strong: #eef4ff;
  --shadow: 0 6px 18px rgba(0,0,0,.08);
  --radius: 14px;
  --max: 980px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 16px;
}

.header-wrap {
  padding-top: 16px;
  padding-bottom: 16px;
  padding-left: calc(24px + env(safe-area-inset-left));
  padding-right: calc(24px + env(safe-area-inset-right));
}

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

h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: .2px;
  flex: 0 1 auto;
  min-width: 0;
}

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1 1 auto;
  min-width: 0;
}

.toggle-all-btn,
input[type="search"] {
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  outline: none;
}

.toggle-all-btn {
  flex: 0 0 172px;
  width: 172px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
}

.toggle-all-btn.expand {
  color: #0b57d0;
}

.toggle-all-btn.contract {
  color: #000000;
}

input[type="search"] {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  color: var(--text);
}

input[type="search"]:focus,
.toggle-all-btn:focus {
  border-color: #0b57d0;
  box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.14);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin: 18px 0;
}

.card-head,
.search-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel2);
}

.card-head h2,
.search-head h2 {
  margin: 0;
  font-size: 15px;
}

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

.search-meta {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.ghost-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
}

.hidden { display: none; }

.domain-stack {
  padding: 10px;
  display: grid;
  gap: 12px;
}

.domain-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}

.domain-toggle,
.source-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}

.domain-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
}

.domain-title-wrap {
  min-width: 0;
}

.domain-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #0b57d0;
}

.domain-subtitle {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}


.domain-body {
  display: none;
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, #fff 0%, #fbfdff 100%);
}

.domain-card.open > .domain-body {
  display: block;
}

.source-stack {
  display: grid;
  gap: 10px;
  padding-top: 14px;
}

.source-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.source-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 14px;
}

.source-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.source-meta {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.source-body {
  display: none;
  border-top: 1px solid var(--border);
  padding: 8px;
}

.source-card.open > .source-body {
  display: block;
}

.item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 12px;
}

.item:hover {
  background: color-mix(in srgb, var(--chip) 72%, transparent);
}

.item a {
  color: var(--link);
  text-decoration: none;
  flex: 1;
}

.item a:focus {
  outline: 2px solid color-mix(in srgb, var(--link) 55%, transparent);
  outline-offset: 2px;
  border-radius: 10px;
}

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

.search-results {
  padding: 8px;
  display: grid;
  gap: 6px;
}

.search-result {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}

.search-result-path {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.search-result a {
  color: var(--link);
  text-decoration: none;
  font-weight: 600;
}

.search-empty {
  padding: 14px 12px;
  color: var(--muted);
}

.title-link {
  color: #0b57d0 !important;
  text-decoration: none !important;
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

.title-link:hover { text-decoration: underline !important; }
.title-link:focus,
.title-link:focus-visible,
.title-link:active {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

.title-rest { color: #000 !important; }

@media (max-width: 760px) {
  .header-row {
    flex-wrap: wrap;
    align-items: stretch;
  }

  h1 {
    width: 100%;
  }

  .controls {
    width: 100%;
  }
}

@media (max-width: 680px) {
  .search-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .ghost-btn {
    width: 100%;
  }

  .domain-toggle,
  .source-toggle {
    padding-left: 14px;
    padding-right: 14px;
  }

  .toggle-all-btn {
    flex-basis: 160px;
    width: 160px;
    font-size: 14px;
    padding-left: 10px;
    padding-right: 10px;
  }
}


.domain-header-right {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.domain-score {
  min-width: 52px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--chip);
  color: #0b57d0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.domain-score.placeholder {
  color: #0b57d0;
  background: var(--chip-strong);
}

.domain-score.zero {
  color: #000000;
  background: #f6f8fa;
}

.domain-score.loaded {
  color: #0b57d0;
  background: var(--chip-strong);
}

@media (max-width: 680px) {
  .domain-header-right {
    gap: 10px;
  }

  .domain-score {
    min-width: 46px;
    padding-left: 8px;
    padding-right: 8px;
    font-size: 13px;
  }
}


.auth-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel2);
}

.auth-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.auth-title {
  margin: 0;
  font-size: 15px;
}

.auth-meta {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.signed-in-chip {
  display: inline-flex;
  align-items: center;
  margin-top: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--chip-strong);
  color: #0b57d0;
  font-size: 13px;
  font-weight: 700;
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.google-button-slot.hidden {
  display: none;
}

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

@media (max-width: 760px) {
  .auth-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-actions {
    justify-content: flex-start;
  }
}
