:root {
  --bg: #0b0e14;
  --panel: #101722;
  --panel-2: #0f141d;
  --border: #303846;
  --border-strong: #495364;
  --text: #e6edf3;
  --muted: #98a2b3;
  --dim: #6b7280;
  --cyan: #00d7ff;
  --green: #00ff87;
  --yellow: #ffd700;
  --red: #ff5f87;
  --blue: #87afff;
  --tag: #1d2633;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(0, 215, 255, 0.08), transparent 30%),
    linear-gradient(180deg, #0a0f16, #0b0e14 35%, #090c12);
}

body[data-theme="light"] {
  --text: #0f172a;
  --muted: #475569;
  --dim: #64748b;
  --border: #d7dee9;
  --border-strong: #b8c4d5;
  --tag: #e8eef8;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.10);
  background: linear-gradient(180deg, #f8fbff, #f1f5f9 40%, #e8eef5);
}

body[data-theme="light"] .hero,
body[data-theme="light"] .panel,
body[data-theme="light"] .history-panel,
body[data-theme="light"] .result-panel,
body[data-theme="light"] .history-item {
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(247,250,252,0.98));
}

body[data-theme="light"] .lookup-form input {
  background: #fff;
  color: var(--text);
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; }
button { cursor: pointer; }
strong { color: var(--text); }
code { font-family: var(--mono); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none !important; }

.app-shell {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 80px;
}

.hero, .panel {
  background: linear-gradient(180deg, rgba(16, 23, 34, 0.95), rgba(11, 17, 25, 0.92));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--yellow);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 4.5rem);
  line-height: 0.95;
  color: var(--cyan);
  font-family: var(--mono);
}

.subtitle {
  max-width: 720px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.lookup-panel {
  padding: 16px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

.lookup-layout {
  min-width: 0;
}

.lookup-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.lookup-form input {
  min-width: 0;
  width: 100%;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: #090e15;
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;
}

.lookup-form input:focus {
  outline: 2px solid rgba(0, 215, 255, 0.35);
  border-color: var(--cyan);
}

.lookup-form button, .pill-btn {
  border: 1px solid rgba(0, 215, 255, 0.35);
  background: linear-gradient(180deg, rgba(0, 215, 255, 0.16), rgba(0, 215, 255, 0.08));
  color: var(--text);
  padding: 14px 18px;
  border-radius: 999px;
  font-weight: 700;
}

.lookup-meta, .footer-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: 12px;
  color: var(--dim);
  font-size: 13px;
}

.result-shell {
  margin-bottom: 18px;
  min-width: 0;
  max-width: 100%;
}
.tabbar-wrap {
  position: sticky;
  top: 8px;
  z-index: 10;
  margin-bottom: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.tabbar {
  display: flex;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 4px;
  scrollbar-width: thin;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  border: 1px solid transparent;
  color: #a0a0a0;
  background: transparent;
  border-radius: 999px;
  padding: 10px 14px;
}

.tab .key { color: var(--dim); font-family: var(--mono); }
.tab.active {
  color: var(--cyan);
  font-weight: 700;
  border-color: rgba(0, 215, 255, 0.28);
  background: rgba(0, 215, 255, 0.08);
}
.tab.active .key { color: var(--cyan); }

.frame,
.frame-top,
.frame-bottom,
.result-panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.frame-top, .frame-bottom {
  height: 18px;
  border-left: 1px solid var(--border-strong);
  border-right: 1px solid var(--border-strong);
  position: relative;
}
.frame-top::before, .frame-bottom::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px solid var(--border-strong);
}

.result-panel {
  border-radius: 0;
  border-left: 1px solid var(--border-strong);
  border-right: 1px solid var(--border-strong);
  padding: 14px;
}

.frame-top {
  border-top: 1px solid var(--border-strong);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}
.frame-bottom {
  border-bottom: 1px solid var(--border-strong);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}

.status {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  font-family: var(--mono);
  font-size: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 215, 0, 0.08);
  color: var(--yellow);
}
.status.error {
  background: rgba(255, 95, 135, 0.08);
  color: var(--red);
  border-color: rgba(255, 95, 135, 0.22);
}

.title-line {
  margin: 0 0 8px;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.section {
  margin-top: 18px;
}

.section-title {
  margin: 0 0 10px;
  color: var(--yellow);
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.kv-list {
  display: grid;
  gap: 6px;
}

.kv {
  display: grid;
  grid-template-columns: minmax(88px, 132px) 1fr;
  gap: 10px;
  align-items: start;
}

.kv-label {
  color: var(--dim);
  text-align: right;
  font-size: 14px;
}

.kv-value {
  min-width: 0;
  overflow-wrap: anywhere;
}

.stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--tag);
  color: var(--blue);
  border: 1px solid rgba(135, 175, 255, 0.2);
  font-size: 14px;
}
.tag.green {
  color: #07140d;
  background: var(--green);
  border-color: transparent;
}
.tag.dim {
  color: #111827;
  background: #7b8596;
  border-color: transparent;
}

.muted { color: var(--muted); }
.dim { color: var(--dim); }
.good { color: var(--green); }
.warn { color: var(--yellow); }
.bad { color: var(--red); }
.blue { color: var(--blue); }

.record-block, .raw-block {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #b8c0cc;
  font-family: var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.raw-block {
  max-height: 60vh;
  overflow: auto;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
}

.empty-state {
  color: var(--muted);
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 12px;
}

.info-panel {
  padding: 20px;
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.info-grid h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--text);
}
.info-grid ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}


.history-panel {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background: rgba(255,255,255,0.02);
  padding: 14px;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.history-head h2 {
  margin: 0;
  font-size: 14px;
  color: var(--yellow);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.history-refresh {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
}
.history-list {
  display: grid;
  gap: 10px;
  max-height: 340px;
  overflow: auto;
}
.history-item {
  display: grid;
  gap: 4px;
  text-align: left;
  width: 100%;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  background: #0b1118;
  color: var(--text);
  padding: 12px;
}
.history-item:hover {
  border-color: rgba(0,215,255,0.28);
  background: #0c131d;
}
.history-query {
  font-family: var(--mono);
  overflow-wrap: anywhere;
}
.history-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--dim);
  font-size: 12px;
}
.desktop-grid {
  display: block;
  min-width: 0;
  max-width: 100%;
}
.desktop-grid > * + * {
  margin-top: 18px;
}
.side-panel {
  padding: 18px;
  position: static;
  top: auto;
}
.ascii-box {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--dim);
  white-space: pre-wrap;
}
.result-panel .toolbar .pill-btn {
  background: transparent;
  border-color: rgba(255, 215, 0, 0.3);
}
@media (min-width: 981px) {
  .lookup-panel {
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.9fr);
  }
  .desktop-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
    gap: 18px;
    align-items: start;
  }
  .desktop-grid > * + * {
    margin-top: 0;
  }
  .side-panel {
    position: sticky;
    top: 64px;
  }
}
.side-panel {
  position: static;
}
.history-list {
  max-height: none;
}
@media (max-width: 720px) {
  .app-shell { width: min(100%, calc(100% - 16px)); padding-top: 10px; }
  .hero { padding: 18px; border-radius: 16px; }
  .hero, .lookup-form, .info-grid { grid-template-columns: 1fr; display: grid; }
  .hero-actions { justify-content: flex-start; }
  .lookup-form { grid-template-columns: 1fr; }
  .lookup-form button, .pill-btn, .history-refresh { width: 100%; }
  .result-panel, .side-panel { padding: 14px; }
  .kv { grid-template-columns: 1fr; gap: 4px; }
  .kv-label { text-align: left; }
  .tabbar-wrap { top: 4px; overflow-x: auto; overflow-y: hidden; }
  .tabbar { width: max-content; min-width: 100%; }
  .frame-top, .frame-bottom { height: 12px; }
}

.saved-head {
  margin-top: 18px;
}
.saved-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tui-lines {
  border-top: 1px dashed rgba(255,255,255,0.10);
  border-bottom: 1px dashed rgba(255,255,255,0.10);
  padding: 8px 0;
}

.tabbar-shell {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}
.back-chip {
  flex: 0 0 auto;
  border: 1px solid rgba(0, 215, 255, 0.28);
  background: rgba(0, 215, 255, 0.08);
  color: var(--cyan);
  border-radius: 999px;
  min-width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.dashboard-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background: rgba(255,255,255,0.02);
  padding: 12px;
  min-width: 0;
}
.dashboard-card .section-title {
  margin-bottom: 8px;
}
.dashboard-card .title-line {
  font-size: 1rem;
  margin-bottom: 6px;
}
.compact-list {
  display: grid;
  gap: 6px;
}
.compact-item {
  font-family: var(--mono);
  color: var(--text);
  overflow-wrap: anywhere;
}
body[data-theme="light"] .dashboard-card {
  background: rgba(255,255,255,0.9);
}

.collapse-toggle {
  border: 0;
  background: transparent;
  color: var(--yellow);
  font-family: var(--mono);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.collapse-icon {
  display: inline-flex;
  width: 1ch;
  justify-content: center;
  flex: 0 0 1ch;
}
.dashboard-card.clickable {
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.dashboard-card.clickable:hover {
  transform: translateY(-1px);
  border-color: rgba(0,215,255,0.25);
  background: rgba(0,215,255,0.03);
}
.card-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--dim);
}
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
}
.status-dot.good { background: var(--green); }
.status-dot.warn { background: var(--yellow); }
.status-dot.bad { background: var(--red); }
.status-dot.dim { background: var(--dim); }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: center;
  margin: 18px 0 0;
  padding: 14px 18px 0;
  color: var(--dim);
  font-size: 13px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.site-footer a {
  color: var(--cyan);
}
