* {
  box-sizing: border-box;
}

:root {
  --ink: #0f1622;
  --ink-2: #151f2f;
  --slate: #2b3647;
  --slate-soft: #3b4860;
  --gold: #ddb86a;
  --gold-dark: #8a6630;
  --parchment: #f6e8cb;
  --muted: #b7b9bf;
  --blue-glow: rgba(123, 184, 255, 0.22);
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--parchment);
  font-family: "VT323", "Courier New", monospace;
  font-size: 23px;
  background:
    radial-gradient(1200px 520px at 50% -20%, rgba(95, 139, 212, 0.24), transparent 58%),
    radial-gradient(920px 480px at 100% 8%, rgba(71, 122, 89, 0.17), transparent 62%),
    linear-gradient(180deg, #131f32 0%, #0d1624 43%, #090f18 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.018) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: soft-light;
}

.explorer-search,
.explorer-detail {
  width: min(1220px, 95vw);
  margin: 1.2rem auto 1.4rem;
  display: grid;
  gap: 0.85rem;
}

.explorer-search h1,
#detail-title {
  margin: 0;
  font-family: "Almendra SC", "Times New Roman", serif;
  font-size: clamp(2.1rem, 4.6vw, 3.25rem);
  letter-spacing: 0.04em;
  color: #ffe09d;
  text-shadow: 0 2px 0 rgba(66, 42, 8, 0.9);
}

.explorer-search p {
  margin: 0;
  color: #dad3c3;
  font-size: 1.24rem;
}

.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.live-chip {
  margin-left: auto;
  color: #cff7d8;
  border: 2px solid rgba(110, 196, 125, 0.5);
  background: rgba(23, 63, 39, 0.5);
  padding: 0.2rem 0.45rem;
  line-height: 1;
  font-size: 0.95rem;
}

.live-chip.is-error {
  color: #ffd0d0;
  border-color: rgba(220, 122, 122, 0.6);
  background: rgba(82, 28, 28, 0.5);
}

.back-home,
.back-search {
  text-decoration: none;
  color: #fff2d2;
  font-family: "MedievalSharp", serif;
  border: 2px solid var(--gold-dark);
  background:
    linear-gradient(180deg, rgba(74, 54, 23, 0.94), rgba(42, 29, 14, 0.94)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.038) 0 2px, transparent 2px 5px);
  box-shadow: inset 0 0 0 1px rgba(253, 219, 143, 0.3);
  padding: 0.34rem 0.7rem;
  line-height: 1;
}

.search-card,
.detail-card {
  border: 3px solid #606d80;
  background:
    linear-gradient(180deg, rgba(23, 33, 49, 0.95), rgba(16, 22, 34, 0.95)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.015) 0 3px, transparent 3px 8px);
  box-shadow:
    inset 0 0 0 2px rgba(221, 184, 106, 0.2),
    0 10px 24px rgba(0, 0, 0, 0.4);
  padding: 0.9rem;
}

.overview-panel {
  border: 3px solid #606d80;
  background:
    linear-gradient(180deg, rgba(18, 28, 43, 0.95), rgba(13, 19, 31, 0.96)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.02) 0 3px, transparent 3px 9px);
  box-shadow:
    inset 0 0 0 2px rgba(221, 184, 106, 0.2),
    0 10px 24px rgba(0, 0, 0, 0.4);
  padding: 0.9rem;
  display: grid;
  gap: 0.75rem;
}

.overview-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.overview-top h2,
.overview-chart-wrap h3 {
  margin: 0;
  font-family: "MedievalSharp", serif;
  font-weight: 400;
  color: #f1d59a;
}

.overview-chart-wrap h3 {
  margin-bottom: 0.45rem;
  font-size: 1.08rem;
}

.overview-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}

.stat-card {
  border: 2px solid #4f5f78;
  background: linear-gradient(180deg, #101a2a 0%, #0c141f 100%);
  padding: 0.52rem;
}

.stat-card label {
  display: block;
  margin: 0;
  color: #c6d2e6;
  font-size: 0.95rem;
  line-height: 1;
}

.stat-card strong {
  display: block;
  margin-top: 0.25rem;
  color: #ffe09d;
  font-size: 1.08rem;
  line-height: 1;
}

.overview-chart-wrap {
  border: 2px solid #4f5f78;
  background: linear-gradient(180deg, #0f1726 0%, #0a111b 100%);
  padding: 0.55rem;
}

.overview-bars {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.4rem;
  align-items: end;
  min-height: 210px;
  padding: 0.35rem;
  border: 2px solid rgba(95, 118, 152, 0.55);
  background:
    linear-gradient(180deg, rgba(14, 24, 39, 0.95), rgba(11, 17, 27, 0.95)),
    repeating-linear-gradient(
      0deg,
      rgba(194, 219, 255, 0.08) 0 1px,
      transparent 1px 18px
    );
}

.block-bar {
  display: grid;
  align-items: end;
  min-height: 180px;
}

.bar-link {
  text-decoration: none;
  color: #d9ebff;
  text-align: center;
  font-size: 0.8rem;
  display: grid;
  gap: 0.22rem;
}

.bar-track {
  height: 148px;
  border: 2px solid rgba(98, 117, 148, 0.72);
  background:
    linear-gradient(180deg, rgba(13, 21, 35, 0.95), rgba(9, 15, 24, 0.95));
  padding: 0.12rem;
  display: flex;
  align-items: flex-end;
  box-shadow: inset 0 0 0 1px rgba(24, 36, 53, 0.85);
}

.bar-fill {
  width: 100%;
  border: 2px solid rgba(255, 209, 122, 0.45);
  background:
    linear-gradient(180deg, rgba(255, 204, 115, 0.96), rgba(232, 132, 42, 0.96) 56%, rgba(153, 72, 19, 0.96)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.08) 0 2px, transparent 2px 4px);
  box-shadow:
    0 3px 12px rgba(0, 0, 0, 0.35),
    0 0 14px rgba(255, 168, 75, 0.33);
  height: var(--bar-h, 20%);
  min-height: 14px;
  transform-origin: bottom;
  transform: scaleY(0.12);
  transition: transform 0.45s ease-out, filter 0.25s ease;
  transition-delay: var(--delay, 0ms);
}

.bar-fill.is-ready {
  transform: scaleY(1);
}

.bar-link:hover .bar-fill {
  filter: brightness(1.15) saturate(1.1);
}

.bar-tip {
  color: #ffe6b4;
  font-size: 0.82rem;
  line-height: 1;
}

.bar-meta {
  color: #b7d3f2;
  line-height: 1;
  opacity: 0.96;
}

.bar-time {
  display: block;
  margin-top: 0.2rem;
  color: #9fb8d5;
  font-size: 0.72rem;
  line-height: 1.1;
}

.search-card.compact {
  padding: 0.7rem;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.search-row-tools {
  align-items: center;
}

.search-row-tools label {
  color: #d7e4f7;
  font-size: 0.98rem;
}

.query-kind-chip {
  display: inline-block;
  border: 2px solid #4f5f78;
  background: #101928;
  color: #d8ebff;
  padding: 0.2rem 0.45rem;
  line-height: 1;
  font-size: 0.9rem;
}

.query-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.query-hint {
  border: 2px solid #526889;
  background: linear-gradient(180deg, #223249 0%, #172436 100%);
  color: #d8ebff;
  font-size: 0.9rem;
  padding: 0.24rem 0.45rem;
}

input,
select,
button {
  border: 2px solid #806438;
  background: #161109;
  color: #fff0cf;
  font-family: "VT323", "Courier New", monospace;
  font-size: 1.08rem;
  line-height: 1;
  padding: 0.45rem 0.52rem;
}

input {
  flex: 1;
  min-width: 220px;
}

input::placeholder {
  color: #b8aa8e;
}

button {
  cursor: pointer;
  border-color: #c58a45;
  background:
    linear-gradient(180deg, #a35f25 0%, #653716 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 2px, transparent 2px 5px);
  color: #fff0cb;
}

button:hover {
  filter: brightness(1.12);
}

.result-view {
  margin-top: 0.58rem;
  display: grid;
  gap: 0.75rem;
}

.result-kv {
  margin: 0;
  padding: 0.72rem;
  border: 2px solid #47546a;
  background:
    linear-gradient(180deg, #0f1826 0%, #0b121e 100%);
  display: grid;
  grid-template-columns: minmax(180px, 230px) minmax(0, 1fr);
  gap: 0.36rem 0.6rem;
}

.result-kv dt {
  margin: 0;
  color: var(--gold);
}

.result-kv dd {
  margin: 0;
  color: #e7f1ff;
  overflow-wrap: anywhere;
}

.result-subhead {
  margin: 0;
  font-family: "MedievalSharp", serif;
  font-size: 1.15rem;
  color: #f1d59a;
}

.result-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 2px solid #48556b;
  background: #0d1421;
  max-height: 430px;
  overflow: auto;
}

.result-list li {
  border-bottom: 1px solid rgba(148, 165, 188, 0.18);
  padding: 0.36rem 0.48rem;
  color: #d7e7ff;
  overflow-wrap: anywhere;
}

.result-link {
  color: #cae8ff;
  text-decoration: none;
  border-bottom: 1px dotted rgba(202, 232, 255, 0.54);
}

.result-link:hover {
  color: #ffd483;
  border-bottom-color: rgba(255, 212, 131, 0.8);
}

.result-tables {
  display: grid;
  gap: 0.48rem;
}

.result-mini-table {
  width: 100%;
  border-collapse: collapse;
  border: 2px solid #48556b;
  background: linear-gradient(180deg, #0d1421 0%, #0a1019 100%);
}

.result-mini-table th,
.result-mini-table td {
  border-bottom: 1px solid rgba(148, 165, 188, 0.18);
  padding: 0.33rem 0.4rem;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.result-mini-table th {
  color: var(--gold);
  background: rgba(48, 64, 88, 0.35);
  font-weight: 400;
}

.result-error {
  margin: 0;
  color: #ffb8b8;
  white-space: pre-wrap;
  border: 2px solid rgba(255, 130, 130, 0.35);
  background: rgba(66, 24, 24, 0.35);
  padding: 0.55rem;
}

.beginner-note {
  margin: 0;
  color: #d8e8ff;
  border: 2px solid rgba(112, 148, 198, 0.42);
  background: rgba(19, 35, 55, 0.55);
  padding: 0.45rem 0.52rem;
}

.raw-panel {
  border: 2px solid #52627d;
  background: #0c141f;
  padding: 0.35rem 0.45rem;
}

.raw-panel summary {
  cursor: pointer;
  color: #f2d498;
}

.raw-json {
  margin: 0.35rem 0 0;
  padding: 0.45rem;
  border: 2px solid rgba(76, 96, 125, 0.55);
  background: #0a111a;
  color: #d4e8ff;
  max-height: 420px;
  overflow: auto;
  font-size: 0.86rem;
  line-height: 1.3;
}

@media (max-width: 820px) {
  .explorer-search,
  .explorer-detail {
    width: min(1220px, 96vw);
  }

  .result-kv {
    grid-template-columns: 1fr;
  }

  .overview-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-bars {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    min-height: 240px;
  }
}
