/* ============================================================
   sndoc · MCP playground
   Identity: enterprise-docs tooling. IBM Plex Sans + Plex Mono.
   Palette: deep ServiceNow-teal ink, warm amber signal, light
   "paper" surface for fetched Markdown docs.
   ============================================================ */

:root {
  --bg: #0c1a1b;
  --panel: #102325;
  --panel-2: #16302f;
  --line: #234140;
  --line-soft: #1a3332;
  --text: #dbe7e3;
  --muted: #7f9a95;
  --faint: #5c7671;
  --signal: #f2a65a; /* warm amber — deliberate counter to the green cliché */
  --signal-ink: #1c1206;
  --ok: #57c8a3;
  --bad: #e97b6b;
  --paper: #f5f8f6;
  --paper-ink: #13282a;
  --paper-muted: #4c6663;

  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;

  --r: 10px;
  --r-sm: 7px;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(
      1200px 600px at 85% -10%,
      rgba(242, 166, 90, 0.06),
      transparent 60%
    ),
    radial-gradient(900px 500px at -5% 110%, rgba(87, 200, 163, 0.05), transparent 55%);
  background-attachment: fixed;
}

/* View switching driven by <html data-view> */
[data-when] {
  display: none;
}
html[data-view="login"] [data-when="login"] {
  display: flex;
}
html[data-view="app"] [data-when="app"] {
  display: flex;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 3px rgba(242, 166, 90, 0.15);
  flex: none;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, color 0.15s;
}
.btn:hover {
  border-color: var(--signal);
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}
.btn--go {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--signal-ink);
}
.btn--go:hover {
  background: #f6b877;
}
.btn--go:disabled {
  opacity: 0.55;
  cursor: progress;
}
.btn--ghost {
  color: var(--muted);
}
.btn--ghost:hover {
  color: var(--text);
}
.btn--sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ============================================================
   LOGIN
   ============================================================ */
.gate {
  min-height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 32px;
}
.gate__card {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 38px 34px 34px;
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.9);
}
.gate__mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.protocol {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.gate__title {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 44px;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
  color: var(--text);
}
.cursor {
  color: var(--signal);
  animation: blink 1.15s steps(1) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
.gate__lede {
  color: var(--muted);
  margin: 0 0 26px;
  font-size: 14.5px;
}
.field {
  display: block;
  margin-bottom: 16px;
}
.field__label {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 8px;
}
input[type="password"],
input[type="text"],
textarea {
  width: 100%;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder,
textarea::placeholder {
  color: var(--faint);
}
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px rgba(242, 166, 90, 0.15);
}
.gate__form .btn--go {
  width: 100%;
  margin-top: 4px;
}
.gate__error {
  color: var(--bad);
  font-size: 13.5px;
  margin: 14px 0 0;
  font-family: var(--mono);
}
.gate__foot {
  color: var(--faint);
  font-size: 12.5px;
  max-width: 440px;
  text-align: center;
  margin: 0;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app {
  flex-direction: column;
  height: 100%;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 35, 37, 0.7);
  backdrop-filter: blur(8px);
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar__name {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 17px;
}
.topbar__tag {
  color: var(--faint);
  font-size: 13px;
  border-left: 1px solid var(--line);
  padding-left: 10px;
}
.topbar__meta {
  display: flex;
  align-items: center;
  gap: 14px;
}
.endpoint {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 288px 1fr;
  min-height: 0;
}

/* ---------- Catalog ---------- */
.catalog {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(12, 26, 27, 0.4);
}
.catalog__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 18px 20px 12px;
}
.catalog__title {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}
.catalog__count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--signal);
}
.catalog__list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 12px;
}
.tool-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 12px 13px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
}
.tool-item:hover {
  background: var(--panel);
}
.tool-item.is-active {
  background: var(--panel-2);
  border-color: var(--line);
}
.tool-item.is-active .tool-item__name {
  color: var(--signal);
}
.tool-item__name {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 500;
  word-break: break-word;
}
.tool-item__args {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
  margin-top: 3px;
}
.catalog__status {
  padding: 14px 20px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 12.5px;
}
.catalog__status[hidden] {
  display: none;
}

/* ---------- Console ---------- */
.console {
  min-height: 0;
  overflow-y: auto;
  padding: 30px 32px 60px;
}
.console__empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 14px;
}
.tool {
  max-width: 860px;
  margin: 0 auto;
  animation: rise 0.28s ease both;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.tool__head {
  margin-bottom: 24px;
}
.tool__name {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}
.tool__desc {
  color: var(--muted);
  margin: 0;
  max-width: 62ch;
}

.tool__form {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 22px;
}
.tool__inputs {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.tool__inputs:empty::after {
  content: "No inputs — this tool takes no arguments.";
  color: var(--faint);
  font-family: var(--mono);
  font-size: 13px;
}
.arg__label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.arg__req {
  color: var(--signal);
  font-size: 10px;
  letter-spacing: 0.1em;
}
.arg__opt {
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.1em;
}
.arg__hint {
  display: block;
  color: var(--faint);
  font-size: 12px;
  font-family: var(--sans);
  text-transform: none;
  letter-spacing: 0;
  margin-top: 6px;
}
textarea {
  resize: vertical;
  min-height: 46px;
}
.arg--bool {
  display: flex;
  align-items: center;
  gap: 10px;
}
.arg--bool input {
  width: 16px;
  height: 16px;
  accent-color: var(--signal);
}
.arg--bool .arg__label {
  margin: 0;
}

.tool__run {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}
.rpcline {
  flex: 1;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rpcline b {
  color: var(--muted);
  font-weight: 500;
}
.tool__run .btn--go {
  min-width: 96px;
}

/* ---------- Result ---------- */
.result {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  animation: rise 0.28s ease both;
}
.result__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.result__label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.result__label.is-error {
  color: var(--bad);
}
.result__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.toggle button {
  font-family: var(--mono);
  font-size: 12px;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 6px 12px;
  cursor: pointer;
}
.toggle button.is-active {
  background: var(--panel-2);
  color: var(--signal);
}
.toggle button:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: -2px;
}

/* Light "paper" so ServiceNow docs read like docs */
.result__body {
  background: var(--paper);
  color: var(--paper-ink);
  max-height: 62vh;
  overflow: auto;
}
.markdown {
  padding: 26px 30px;
}
.raw {
  margin: 0;
  padding: 22px 26px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--paper-ink);
  white-space: pre-wrap;
  word-break: break-word;
}
.raw[hidden],
.markdown[hidden] {
  display: none;
}

/* Markdown typography on paper */
.markdown h1,
.markdown h2,
.markdown h3 {
  font-family: var(--sans);
  line-height: 1.25;
  margin: 1.4em 0 0.5em;
}
.markdown h1 {
  font-size: 1.6em;
}
.markdown h2 {
  font-size: 1.3em;
}
.markdown h3 {
  font-size: 1.1em;
}
.markdown > :first-child {
  margin-top: 0;
}
.markdown p,
.markdown li {
  color: #24413f;
}
.markdown a {
  color: #b06a1e;
  text-underline-offset: 2px;
}
.markdown code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: #e5ece8;
  padding: 0.1em 0.4em;
  border-radius: 4px;
}
.markdown pre {
  background: #13282a;
  color: #dbe7e3;
  padding: 16px 18px;
  border-radius: var(--r-sm);
  overflow-x: auto;
}
.markdown pre code {
  background: none;
  padding: 0;
  color: inherit;
}
.markdown table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  font-size: 0.92em;
}
.markdown th,
.markdown td {
  border: 1px solid #d3ddd8;
  padding: 8px 11px;
  text-align: left;
}
.markdown th {
  background: #e9efeb;
}
.markdown blockquote {
  border-left: 3px solid var(--signal);
  margin: 1em 0;
  padding: 0.2em 1em;
  color: var(--paper-muted);
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(28, 18, 6, 0.35);
  border-top-color: var(--signal-ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 800px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .catalog {
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 34vh;
  }
  .console {
    padding: 22px 18px 48px;
  }
  .endpoint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
