:root {
  color-scheme: dark;
  --bg: #050033;
  --bg-mid: #0a0045;
  --panel: #0b0a3c;
  --panel-elevated: #12104a;
  --border: #2b2566;
  --primary: #e8edf5;
  --secondary: #8d8ab8;
  --lime: #91e617;
  --lime-bright: #00ff57;
  --accent-blue: #00a3ff;
  --gold: #f5c842;
  --danger: #ff5c7a;
  --warn: #f5c842;
  --ok: #91e617;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Plus Jakarta Sans", Inter, system-ui, sans-serif;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --chrome: 7.5rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--primary);
  background: var(--bg);
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(145, 230, 23, 0.35);
  color: #fff;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 520px at 8% -10%, rgba(145, 230, 23, 0.12), transparent 55%),
    radial-gradient(700px 480px at 92% 0%, rgba(0, 163, 255, 0.14), transparent 50%),
    linear-gradient(180deg, #050033 0%, #0a0045 55%, #050033 100%);
}

.top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid rgba(43, 37, 102, 0.95);
  background: linear-gradient(180deg, rgba(5, 0, 51, 0.96), rgba(11, 10, 60, 0.72));
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  height: 2.15rem;
  width: auto;
  display: block;
  filter: drop-shadow(0 0 10px rgba(145, 230, 23, 0.12));
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.brand-text strong {
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.brand-text em {
  font-style: normal;
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--secondary);
  font-weight: 600;
}

.top-center {
  display: flex;
  align-items: end;
  gap: 0.45rem;
  min-width: 0;
}

.key-inline {
  flex: 1;
  min-width: 0;
  max-width: 28rem;
}

.key-inline > span,
.block-label,
.field-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--secondary);
  margin-bottom: 0.28rem;
}

.field {
  display: block;
  min-width: 0;
}

.field.grow {
  flex: 1;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(43, 37, 102, 0.95);
  background: rgba(18, 16, 74, 0.55);
  border-radius: 12px;
  padding: 0.62rem 0.8rem;
  color: var(--primary);
  outline: none;
}

#apiKey {
  font-family: var(--mono);
  font-size: 0.84rem;
}

input:focus,
select:focus {
  border-color: rgba(145, 230, 23, 0.45);
  box-shadow: 0 0 0 3px rgba(145, 230, 23, 0.12);
}

.top-nav {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.top-nav a {
  color: var(--secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}

.top-nav a:hover {
  color: var(--lime);
}

.mode-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.25rem;
  padding: 0.85rem clamp(1rem, 3vw, 2rem) 0.75rem;
}

.mode-switch {
  display: inline-flex;
  padding: 0.22rem;
  gap: 0.22rem;
  border: 1px solid rgba(43, 37, 102, 0.95);
  border-radius: 999px;
  background: rgba(18, 16, 74, 0.55);
}

.mode-switch button {
  border: 0;
  background: transparent;
  padding: 0.48rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--secondary);
  font-weight: 700;
  font-size: 0.88rem;
}

.mode-switch button[aria-selected="true"] {
  background: rgba(145, 230, 23, 0.12);
  color: var(--lime);
}

.hint {
  margin: 0;
  color: var(--secondary);
  font-size: 0.84rem;
}

.hint strong {
  color: var(--lime);
  font-weight: 700;
}

.workspace {
  flex: 1;
  min-height: 0;
  padding: 0 clamp(1rem, 3vw, 2rem) 0.75rem;
  display: flex;
}

.panel-full {
  display: none;
  flex: 1;
  min-height: 0;
  border: 1px solid rgba(43, 37, 102, 0.95);
  border-radius: var(--radius);
  background: linear-gradient(
    145deg,
    rgba(18, 16, 74, 0.92) 0%,
    rgba(11, 10, 60, 0.78) 100%
  );
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-full.is-active {
  display: flex;
  flex-direction: column;
}

#graphiql {
  flex: 1;
  min-height: 0;
  height: calc(100dvh - var(--chrome));
}

#graphiql .graphiql-container {
  border-radius: 0;
}

/* Wider Explorer / Docs plugin pane + usable argument inputs */
#graphiql .graphiql-sidebar + .graphiql-plugin,
#graphiql .graphiql-plugin {
  min-width: min(420px, 42vw);
  flex: 1 1 420px;
}

#graphiql .docExplorerWrap,
#graphiql .graphiql-explorer-root {
  min-width: 0;
  width: 100%;
}

#graphiql .graphiql-explorer-root {
  font-size: 0.92rem !important;
}

#graphiql .graphiql-explorer-graphql-arguments input,
#graphiql .graphiql-explorer-root input[type="text"],
#graphiql .graphiql-explorer-root input:not([type="checkbox"]) {
  min-width: 8rem !important;
  width: 8rem !important;
  max-width: 100% !important;
  line-height: 1.35 !important;
  padding: 0.35rem 0.5rem !important;
  box-sizing: border-box;
}

#graphiql .graphiql-explorer-root select {
  min-width: 8rem;
  max-width: 100%;
}

#graphiql .graphiql-explorer-field-name,
#graphiql .graphiql-explorer-graphql-field {
  white-space: normal;
  word-break: break-word;
}

.loading {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--secondary);
  font-size: 1rem;
  font-weight: 600;
}

.live-shell {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

@media (min-width: 900px) {
  .toolbar:not(.channel-row):not(.books-row) {
    grid-template-columns: 1.4fr 1fr;
  }
}

.channel-row {
  grid-template-columns: 1fr;
}

.channel-row .grow {
  min-width: 0;
}

.books-block.is-scores-only {
  opacity: 0.55;
}

.books-block.is-scores-only .books-dd,
.books-block.is-scores-only .books-side {
  pointer-events: none;
}

.books-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.55rem;
}

.books-search-field {
  width: min(100%, 280px);
  flex: 0 1 280px;
}

.books-subhint {
  display: block;
  margin: 0 0 0.45rem;
  color: var(--secondary);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
}

.books-side {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  padding-bottom: 0.1rem;
}

.books-dd {
  position: relative;
  z-index: 30;
}

.books-dd.is-open #wsBooksFilter {
  border-color: rgba(145, 230, 23, 0.45);
  box-shadow: 0 0 0 3px rgba(145, 230, 23, 0.12);
}

#wsBooksFilter {
  width: 100%;
}

#wsBooksFilter:disabled {
  opacity: 0.6;
}

.books-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: max(100%, 280px);
  min-width: 100%;
  z-index: 40;
  border: 1px solid rgba(43, 37, 102, 0.95);
  border-radius: 12px;
  background: #12104a;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.books-menu[hidden] {
  display: none;
}

.live-shell.books-menu-open {
  overflow: visible;
}

.books-list {
  max-height: 240px;
  overflow: auto;
  padding: 0.35rem;
}

.books-empty {
  padding: 0.75rem 0.65rem;
  color: var(--secondary);
  font-size: 0.85rem;
}

.books-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.books-option:hover {
  background: rgba(145, 230, 23, 0.08);
}

.books-option.is-on {
  background: rgba(145, 230, 23, 0.14);
  color: var(--lime);
}

.books-check {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  border-radius: 5px;
  border: 1.5px solid rgba(141, 138, 184, 0.7);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  line-height: 1;
  color: transparent;
  background: rgba(5, 0, 51, 0.35);
}

.books-option.is-on .books-check {
  border-color: var(--lime);
  background: rgba(145, 230, 23, 0.2);
  color: var(--lime);
}

.books-chosen {
  margin: 0.15rem 0 0;
  color: var(--secondary);
  font-size: 0.82rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  min-height: 1.5rem;
}

.books-chosen.is-error {
  color: var(--danger);
}

.books-chosen-label {
  margin-right: 0.15rem;
}

.book-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  border: 1px solid rgba(145, 230, 23, 0.35);
  background: rgba(145, 230, 23, 0.12);
  color: var(--lime);
  padding: 0.2rem 0.35rem 0.2rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.book-chip button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
}

.book-chip button:hover {
  background: rgba(145, 230, 23, 0.2);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: end;
}

.presets button,
.ghost,
.primary {
  cursor: pointer;
  border-radius: 12px;
  border: 1px solid rgba(43, 37, 102, 0.95);
  padding: 0.58rem 0.85rem;
  background: rgba(18, 16, 74, 0.55);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.84rem;
}

.presets button:hover,
.ghost:hover {
  border-color: rgba(145, 230, 23, 0.35);
  color: var(--lime);
  background: rgba(145, 230, 23, 0.08);
}

.primary {
  border-color: transparent;
  background: linear-gradient(160deg, var(--lime), #6fbf10);
  color: #050033;
}

.primary:hover {
  filter: brightness(1.05);
}

.primary:disabled,
.ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.live-actions {
  margin: 0.15rem 0 0.85rem;
}

.out {
  margin: 0;
  flex: 1;
  min-height: 280px;
  overflow: auto;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(43, 37, 102, 0.95);
  background: rgba(5, 0, 51, 0.85);
  color: #d8ffe0;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: rgba(145, 230, 23, 0.35) transparent;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--secondary);
}

.status::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}

.status[data-state="connecting"] {
  color: var(--warn);
}

.status[data-state="connected"] {
  color: var(--ok);
}

.status[data-state="connected"]::before {
  animation: pulse 1.4s ease-in-out infinite;
}

.status[data-state="error"] {
  color: var(--danger);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.35);
    opacity: 0.55;
  }
}

.foot {
  padding: 0.55rem clamp(1rem, 3vw, 2rem) 0.9rem;
  color: var(--secondary);
  font-size: 0.8rem;
  border-top: 1px solid rgba(43, 37, 102, 0.6);
}

@media (max-width: 860px) {
  .top {
    grid-template-columns: 1fr auto;
  }

  .top-center {
    grid-column: 1 / -1;
    order: 3;
  }

  #graphiql {
    height: calc(100dvh - 11rem);
  }
}
