:root {
  --bg: #05060a;
  --bg-2: #090b12;
  --text: #f2f4fa;
  --text-dim: #a6aec2;
  --text-faint: #626b82;
  --violet: #8b5cff;
  --blue: #4d8cff;
  --cyan: #24d6ea;
  --pink: #ff5db1;
  --accent: #8b5cff;
  --accent-2: #24d6ea;
  --danger: #ff6b7a;
  --add: #34e0a1;
  --del: #ff6b7a;
  --chg: #ffc65c;

  --glass: rgba(255, 255, 255, 0.045);
  --glass-2: rgba(255, 255, 255, 0.06);
  --glass-brd: rgba(255, 255, 255, 0.09);
  --glass-brd-strong: rgba(255, 255, 255, 0.16);

  --radius: 18px;
  --radius-sm: 12px;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --grad: linear-gradient(135deg, var(--violet), var(--blue) 45%, var(--cyan));
  --sidebar-w: 256px;
}

[data-theme="light"] {
  --bg: #eef1f8;
  --bg-2: #e7ebf5;
  --text: #10131c;
  --text-dim: #4a5262;
  --text-faint: #8b93a5;
  --glass: rgba(255, 255, 255, 0.55);
  --glass-2: rgba(255, 255, 255, 0.7);
  --glass-brd: rgba(15, 19, 30, 0.08);
  --glass-brd-strong: rgba(15, 19, 30, 0.14);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.006em;
  overflow-x: hidden;
}

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--violet); color: #fff; padding: 10px 16px; border-radius: 0 0 10px 0;
}
.skip-link:focus { left: 0; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 3px; border-radius: 8px; }

/* ---------------- Animated background ---------------- */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bg__grid {
  position: absolute; inset: -2px;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 40%, transparent 100%);
}
[data-theme="light"] .bg__grid {
  background-image:
    linear-gradient(to right, rgba(15,19,30,0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15,19,30,0.04) 1px, transparent 1px);
}
.bg__blob {
  position: absolute; border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  will-change: transform;
}
.bg__blob--1 { width: 620px; height: 620px; left: -160px; top: -180px;
  background: radial-gradient(circle at 30% 30%, var(--violet), transparent 70%);
  animation: drift1 22s ease-in-out infinite; }
.bg__blob--2 { width: 560px; height: 560px; right: -140px; top: 4%;
  background: radial-gradient(circle at 60% 40%, var(--cyan), transparent 70%);
  animation: drift2 26s ease-in-out infinite; }
.bg__blob--3 { width: 640px; height: 640px; left: 30%; bottom: -260px;
  background: radial-gradient(circle at 50% 50%, var(--pink), transparent 70%);
  opacity: 0.35; animation: drift3 30s ease-in-out infinite; }
[data-theme="light"] .bg__blob { opacity: 0.35; }

@keyframes drift1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(80px,60px) scale(1.1); } }
@keyframes drift2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-70px,50px) scale(1.08); } }
@keyframes drift3 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(50px,-60px) scale(1.12); } }

/* ---------------- App shell ---------------- */
.app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------------- Sidebar (glass) ---------------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  margin: 14px 0 14px 14px;
  height: calc(100vh - 28px);
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: 22px;
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  display: flex; flex-direction: column;
  padding: 20px 14px; gap: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.brand__mark {
  font-family: var(--mono); font-weight: 700; font-size: 14px; color: #fff;
  background: var(--grad);
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(139, 92, 255, 0.5);
}
.brand__name { margin: 0; font-weight: 800; font-size: 15px; letter-spacing: -0.02em; }
.brand__tag { margin: 0; font-size: 11px; color: var(--text-faint); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 20px; }
.nav__item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 10px 12px;
  border: 1px solid transparent; background: transparent;
  color: var(--text-dim); border-radius: 12px;
  cursor: pointer; font-family: inherit; font-size: 13.5px; font-weight: 500;
  text-align: left; transition: background .18s, color .18s, border-color .18s, transform .18s;
}
.nav__item svg { width: 18px; height: 18px; flex: none; opacity: .8; transition: opacity .18s, transform .18s; }
.nav__item:hover { color: var(--text); background: var(--glass-2); transform: translateX(2px); }
.nav__item:hover svg { opacity: 1; }
.nav__item.is-active {
  color: #fff;
  background: linear-gradient(135deg, rgba(139,92,255,0.28), rgba(36,214,234,0.18));
  border-color: var(--glass-brd-strong);
  box-shadow: 0 8px 24px rgba(139, 92, 255, 0.28), inset 0 1px 0 rgba(255,255,255,0.12);
}
[data-theme="light"] .nav__item.is-active { color: var(--text); }
.nav__item.is-active svg { opacity: 1; color: #fff; }
[data-theme="light"] .nav__item.is-active svg { color: var(--violet); }

.sidebar__foot { padding-top: 12px; border-top: 1px solid var(--glass-brd); }
.theme-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
  border: 1px solid var(--glass-brd); background: var(--glass-2);
  color: var(--text-dim); border-radius: 12px;
  cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 500;
  transition: color .18s, border-color .18s;
}
.theme-btn:hover { color: var(--text); border-color: var(--glass-brd-strong); }
.theme-btn__icon { width: 17px; height: 17px; }

/* ---------------- Content ---------------- */
.content { min-width: 0; height: 100vh; overflow-y: auto; }
main { max-width: 1080px; margin: 0 auto; padding: 48px 44px 40px; }

.panel { animation: rise .4s cubic-bezier(.2,.7,.2,1); }
.panel[hidden] { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.panel__head { margin-bottom: 30px; }
.panel__head h1 {
  margin: 0 0 8px; font-size: 32px; font-weight: 800; letter-spacing: -0.035em;
  background: linear-gradient(120deg, var(--text) 30%, var(--text-dim));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.panel__head p { margin: 0; color: var(--text-dim); font-size: 14.5px; max-width: 64ch; }
.panel__head code {
  font-family: var(--mono);
  background: linear-gradient(135deg, rgba(139,92,255,0.16), rgba(36,214,234,0.12));
  padding: 2px 7px; border-radius: 6px; font-size: 12.5px; color: var(--cyan);
  border: 1px solid var(--glass-brd);
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 780px) { .grid { grid-template-columns: 1fr; } }

/* Glass cards */
.card {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px; min-width: 0;
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  box-shadow: 0 14px 44px rgba(0,0,0,0.28);
  transition: border-color .2s, transform .2s;
}
.card:hover { border-color: var(--glass-brd-strong); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card__head label { font-weight: 700; font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .08em; }
.card__actions { display: flex; align-items: center; gap: 8px; }
.hint { font-size: 12px; color: var(--text-faint); }

.code-input {
  width: 100%; min-height: 230px; resize: vertical;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--glass-brd);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--mono);
  font-size: 12.5px; line-height: 1.7; padding: 14px; tab-size: 2;
  transition: border-color .18s, box-shadow .18s;
}
[data-theme="light"] .code-input { background: rgba(255,255,255,0.6); }
.code-input::placeholder { color: var(--text-faint); }
.code-input:focus { border-color: var(--violet); outline: none; box-shadow: 0 0 0 3px rgba(139,92,255,0.18); }

.code-output {
  margin: 0; background: rgba(0,0,0,0.32);
  border: 1px solid var(--glass-brd); border-radius: var(--radius-sm);
  padding: 16px; overflow: auto; min-height: 120px; max-height: 500px;
}
[data-theme="light"] .code-output { background: rgba(255,255,255,0.6); }
.code-output code { font-family: var(--mono); font-size: 12.5px; line-height: 1.75; color: var(--text); white-space: pre; }

/* Buttons & selects */
.btn {
  background: var(--grad); background-size: 160% 160%;
  border: none; color: #fff; padding: 10px 18px; border-radius: 12px;
  cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600;
  transition: transform .14s, box-shadow .14s, background-position .4s;
  box-shadow: 0 8px 22px rgba(139, 92, 255, 0.35);
}
.btn:hover { transform: translateY(-2px); background-position: 100% 100%; box-shadow: 0 12px 30px rgba(139, 92, 255, 0.5); }
.btn:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }
.btn--ghost {
  background: var(--glass-2); color: var(--text-dim);
  border: 1px solid var(--glass-brd); box-shadow: none;
}
.btn--ghost:hover { color: var(--text); transform: translateY(-1px); border-color: var(--glass-brd-strong); box-shadow: none; background-position: 0 0; }

.select {
  background: var(--glass-2); border: 1px solid var(--glass-brd); color: var(--text);
  padding: 9px 12px; border-radius: 12px; font-family: inherit; font-size: 13px; cursor: pointer;
  backdrop-filter: blur(8px);
}
.select option { background: var(--bg-2); color: var(--text); }

.toolbar { display: flex; align-items: center; gap: 12px; margin: 22px 0; flex-wrap: wrap; }
.checkline { font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 8px; cursor: pointer; }
.summary { font-size: 13px; color: var(--text-dim); margin-left: auto; }

.msg { margin: 6px 0 0; font-size: 13px; }
.msg--error { color: var(--danger); }

/* Result list */
.diff-result {
  border: 1px solid var(--glass-brd); border-radius: var(--radius); overflow: hidden;
  background: var(--glass); backdrop-filter: blur(16px);
  box-shadow: 0 14px 44px rgba(0,0,0,0.28);
}
.diff-result:empty { display: none; }
.diff-row {
  display: grid; grid-template-columns: 100px 1fr; gap: 14px;
  padding: 12px 18px; border-bottom: 1px solid var(--glass-brd);
  font-family: var(--mono); font-size: 12.5px; align-items: baseline;
}
.diff-row:last-child { border-bottom: none; }
.diff-tag { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.diff-tag--add { color: var(--add); }
.diff-tag--del { color: var(--del); }
.diff-tag--chg { color: var(--chg); }
.diff-path { color: var(--text); word-break: break-all; }
.diff-vals { color: var(--text-dim); margin-top: 3px; }
.diff-vals .old { color: var(--del); text-decoration: line-through; }
.diff-vals .new { color: var(--add); }
.diff-none { padding: 24px; text-align: center; color: var(--add); font-weight: 600; }

/* Field list */
.fields { max-height: 360px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.fields .empty { color: var(--text-faint); font-size: 13px; margin: 8px 0; }
.field {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 9px 10px; border-radius: 10px; font-family: var(--mono); font-size: 12px;
}
.field:hover { background: var(--glass-2); }
.field__path { color: var(--cyan); word-break: break-all; }
.field__val { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.field__type { color: var(--text-faint); font-size: 11px; }

.foot { padding: 30px 44px; text-align: center; color: var(--text-faint); font-size: 12.5px; }
.foot__dot { margin: 0 6px; }

/* Toast */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--grad); color: #fff;
  padding: 12px 22px; border-radius: 999px; font-size: 13px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity .22s, transform .22s; z-index: 50;
  box-shadow: 0 14px 40px rgba(139, 92, 255, 0.5);
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Custom scrollbars */
.content::-webkit-scrollbar, .code-output::-webkit-scrollbar, .fields::-webkit-scrollbar { width: 10px; height: 10px; }
.content::-webkit-scrollbar-thumb, .code-output::-webkit-scrollbar-thumb, .fields::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1); border-radius: 20px; border: 3px solid transparent; background-clip: content-box;
}
.content::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); background-clip: content-box; }

/* ---------------- Responsive ---------------- */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; margin: 12px 12px 0;
    flex-direction: row; align-items: center; flex-wrap: wrap; padding: 12px; gap: 8px;
  }
  .brand { padding: 0 8px 0 0; }
  .brand__text { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1; gap: 6px; }
  .nav__item { width: auto; padding: 9px 11px; }
  .nav__item span { display: none; }
  .content { height: auto; }
  main { padding: 26px 18px 32px; }
  .panel__head h1 { font-size: 26px; }
  .sidebar__foot { padding-top: 0; border-top: none; }
  .theme-btn span { display: none; }
  .theme-btn { padding: 9px 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, .bg__blob { animation: none !important; transition: none !important; }
}
