:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16191f;
  --muted: #5b6270;
  --border: #d9dde5;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --surface: #171b21;
    --text: #e8ebf0;
    --muted: #9aa3b2;
    --border: #2a303a;
    --accent: #6ea8fe;
    --accent-text: #0f1216;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1216;
  --surface: #171b21;
  --text: #e8ebf0;
  --muted: #9aa3b2;
  --border: #2a303a;
  --accent: #6ea8fe;
  --accent-text: #0f1216;
}

* { box-sizing: border-box; }

/* Author display rules (e.g. .account-layout) must not override the hidden attribute */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

a.brand { color: inherit; text-decoration: none; }

.btn.is-current { color: var(--accent); border-color: var(--accent); }

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}
.status { color: var(--muted); font-size: 13px; }

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.search {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.search:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.tab {
  padding: 8px 12px;
  font: inherit;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

.tab.is-active {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

.count {
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

.results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 240px;
}

.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
}

.empty-title { margin: 0 0 4px; color: var(--text); font-weight: 600; }
.empty-body { margin: 0; }

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table th {
  color: var(--muted);
  font-weight: 600;
}

@media (max-width: 480px) {
  .topbar { flex-direction: column; align-items: flex-start; }
}

.btn {
  padding: 8px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.btn-small { padding: 4px 10px; font-size: 13px; }

.btn-ghost { background: transparent; }

.btn:disabled { opacity: 0.6; cursor: default; }

.detail {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

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

.detail-title { margin: 0; font-size: 18px; }
.detail-sub { margin: 20px 0 8px; font-size: 14px; color: var(--muted); }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

.pair-label { font-size: 12px; color: var(--muted); }
.pair-value { word-break: break-word; }
.pair-value.masked { letter-spacing: 0.15em; color: var(--muted); }

.link-group { margin-bottom: 10px; }
.link-title { font-weight: 600; margin-bottom: 4px; }
.link-item { margin: 2px 4px 2px 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

.results .table-wrap { overflow-x: auto; }

@media (max-width: 480px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.login,
.account {
  max-width: 420px;
  margin: 24px auto;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.form { display: grid; gap: 12px; }

.field { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }

.field input {
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.form .btn { justify-self: start; }

.login,
.account { width: 100%; }

.form { grid-template-columns: minmax(0, 1fr); }

.field input { width: 100%; min-width: 0; box-sizing: border-box; }

.row-link { cursor: pointer; }
.row-link:hover td { background: var(--bg); }
.row-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.more-wrap { display: flex; justify-content: center; padding: 12px; }

.search-form { display: flex; gap: 8px; }
.search-form .search { flex: 1; min-width: 0; }
.search-btn { padding: 12px 16px; white-space: nowrap; }

/* Results: dark-blue header strip with white text */
.table thead th {
  background: #1e3a8a;
  color: #ffffff;
  font-weight: 600;
  border-bottom: none;
  position: sticky;
  top: 0;
}
.table tbody tr.is-selected td { background: var(--bg); font-weight: 600; }

.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.results-actions { display: flex; gap: 6px; }

/* Account: side menu + pages */
.account-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  margin-top: 16px;
}
.side-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: start;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.side-item {
  text-align: left;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.side-item.is-active { background: #1e3a8a; color: #ffffff; }
.side-logout { margin-top: 8px; color: var(--muted); }
.account-pages { min-width: 0; }
.page {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.guide { padding-left: 20px; margin: 8px 0 12px; }
.guide li { margin-bottom: 6px; }

.preview { margin-top: 16px; display: grid; gap: 10px; }
.pair-wide { grid-column: 1 / -1; }
.source-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.source-row .pair-value { word-break: break-all; }

@media (max-width: 640px) {
  .account-layout { grid-template-columns: 1fr; }
  .side-menu { flex-direction: row; flex-wrap: wrap; }
  .side-logout { margin-top: 0; }
}

.ref-list { max-height: 240px; overflow: auto; margin: 6px 0 0; padding-left: 20px; font-size: 13px; }
