:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1a2233;
  --text-dim: #5b6577;
  --border: #dfe3ea;
  --accent: #4f5df0;
  --accent-soft: #eceeff;
  --ok: #157347;
  --ok-soft: #e0f3e9;
  --warn: #8a6d1a;
  --warn-soft: #faf1d6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --radius: 12px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101420;
    --surface: #1a2030;
    --surface-2: #232a3d;
    --text: #e6e9f0;
    --text-dim: #98a1b3;
    --border: #2c3448;
    --accent: #8b96ff;
    --accent-soft: #262d4d;
    --ok: #6fd39a;
    --ok-soft: #1c3529;
    --warn: #e3c96e;
    --warn-soft: #3a2f14;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  padding-bottom: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: block; flex: none; border-radius: 9px; box-shadow: 0 2px 8px -2px rgba(99, 102, 241, .5); }
.brand h1 { font-size: 1.15rem; margin: 0; letter-spacing: -.01em; }
.tagline { margin: 0; font-size: .8rem; color: var(--text-dim); }
.api-link {
  font-size: .85rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 999px;
}
.api-link:hover { background: var(--accent-soft); }
.header-actions { display: flex; align-items: center; gap: 12px; flex: none; }
.gh-link { display: flex; color: var(--text-dim); }
.gh-link:hover { color: var(--text); }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin: 20px 0 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  overflow-x: auto;
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); color: #fff; }

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 8px;
}
.search-box {
  flex: 1 1 260px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--text-dim);
}
.search-box:focus-within { border-color: var(--accent); color: var(--accent); }
.search-box input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 11px 0;
  font-size: .95rem;
  color: var(--text);
  outline: none;
  min-width: 0;
}
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.chip-group {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}
.chip {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: .85rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 9px;
  cursor: pointer;
}
.chip.active { background: var(--accent-soft); color: var(--accent); }
select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 10px;
  font-size: .85rem;
}

/* Results bar */
.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .82rem;
  color: var(--text-dim);
  margin: 10px 2px;
  gap: 8px;
}
.per-page { display: flex; align-items: center; gap: 6px; }
.per-page select { padding: 4px 6px; border-radius: 8px; }

/* List */
.list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.row:first-child { border-top: 0; }
.row:hover { background: var(--surface-2); }
.icon-chip {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.icon-chip img { max-width: 36px; max-height: 36px; }
.icon-chip picture { display: contents; }
.icon-chip.themed { background: var(--surface); }
.icon-chip.placeholder { color: #a8b0bf; font-size: 1.2rem; background: var(--surface-2); }
.row-main { min-width: 0; }
.row-name {
  font-weight: 600;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .76rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-side { display: flex; gap: 6px; align-items: center; }

.badge {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .03em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.type { background: var(--accent-soft); color: var(--accent); text-transform: uppercase; }
.badge.provider { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

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

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 20px 0 8px;
}
.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: default; }
.page-ellipsis { color: var(--text-dim); padding: 0 2px; }

/* Footer */
.site-footer {
  margin: 28px auto 32px;
  font-size: .78rem;
  color: var(--text-dim);
  text-align: center;
}
.site-footer a { color: var(--text-dim); }

/* Detail dialog */
.detail-dialog {
  border: 0;
  outline: none;
  border-radius: 16px;
  padding: 0;
  width: min(680px, calc(100vw - 24px));
  max-height: min(85vh, 900px);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px -16px rgba(0,0,0,.35);
}
.detail-dialog::backdrop { background: rgba(10, 14, 24, .55); backdrop-filter: blur(2px); }
.detail-content { padding: 22px 24px 26px; }
.detail-head { display: flex; gap: 16px; align-items: center; margin-bottom: 4px; }
.detail-head .icon-chip { width: 64px; height: 64px; border-radius: 14px; flex: none; }
.detail-head .icon-chip img { max-width: 52px; max-height: 52px; }
.detail-title { min-width: 0; flex: 1; }
.detail-title h2 { margin: 0 0 2px; font-size: 1.15rem; line-height: 1.3; }
.detail-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.close-btn {
  border: 0;
  background: var(--surface-2);
  color: var(--text-dim);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  font-size: 1rem;
  cursor: pointer;
  flex: none;
  align-self: flex-start;
}
.close-btn:hover { color: var(--text); }

.id-line {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 14px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem;
  overflow-wrap: anywhere;
}
.copy-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 3px 10px;
  font-size: .75rem;
  cursor: pointer;
  flex: none;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }

.detail-desc { color: var(--text-dim); font-size: .9rem; margin: 0 0 14px; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.kv {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 12px;
}
.kv dt { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); margin: 0 0 2px; }
.kv dd { margin: 0; font-size: .85rem; font-weight: 600; overflow-wrap: anywhere; }

.detail-section h3 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  margin: 18px 0 8px;
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 3px 9px;
  font-size: .78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 14px 22px;
  font-size: .85rem;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 8.5px;
  top: 16px;
  bottom: -2px;
  width: 1px;
  background: var(--border);
}
.timeline .tl-date { color: var(--text-dim); font-size: .76rem; }
.timeline .tl-extra { color: var(--text-dim); font-size: .78rem; }
.timeline a { color: var(--accent); }

.raw-link {
  display: inline-block;
  margin-top: 16px;
  font-size: .82rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.raw-link:hover { text-decoration: underline; }

.detail-loading { padding: 60px 0; text-align: center; color: var(--text-dim); }
.aka { margin: 0 0 4px; font-size: .78rem; color: var(--text-dim); }

/* API docs dialog */
.api-link { cursor: pointer; background: transparent; font: inherit; }
.docs-dialog h4 {
  font-size: .8rem;
  margin: 14px 0 6px;
  color: var(--text-dim);
  font-weight: 600;
}
.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
}
.docs-table td {
  padding: 7px 10px 7px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.docs-table td:first-child { white-space: nowrap; }
.docs-table code, .detail-desc code {
  background: var(--surface-2);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: .8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.docs-code {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: .76rem;
  line-height: 1.7;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (max-width: 560px) {
  .docs-table td:first-child { white-space: normal; }
}

/* Mobile */
@media (max-width: 560px) {
  .row { grid-template-columns: 48px 1fr; padding: 12px 14px; }
  .row-side { grid-column: 2; justify-content: flex-start; margin-top: 2px; }
  .icon-chip { width: 40px; height: 40px; }
  .icon-chip img { max-width: 32px; max-height: 32px; }
  .row-id { font-size: .7rem; }
  .results-bar { flex-direction: row; }
  .detail-content { padding: 18px 16px 22px; }
  .kv-grid { grid-template-columns: 1fr 1fr; }
}
