:root {
      --bg: #020617;
      --bg-card: #020617;
      --bg-alt: #020617;
      --border-subtle: #1e293b;
      --accent: #3b82f6;
      --accent-soft: #1d283a;
      --text-main: #e5e7eb;
      --text-muted: #9ca3af;
      --danger: #f97373;
      --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      padding: 1.5rem;
      background: radial-gradient(circle at top, #1e293b 0, #020617 50%, #000 100%);
      color: var(--text-main);
      font-family: var(--font);
      min-height: 100vh;
      display: flex;
      justify-content: center;
    }

    .app {
      width: 100%;
      max-width: 1100px;
      border-radius: 1rem;
      border: 1px solid var(--border-subtle);
      background: radial-gradient(circle at top left, #0f172a 0, #020617 50%, #020617 100%);
      padding: 1.5rem;
      box-shadow: 0 18px 40px rgba(0,0,0,0.75);
    }

    header {
      display: flex;
      justify-content: space-between;
      gap: 1rem;
      margin-bottom: 1.25rem;
      flex-wrap: wrap;
      align-items: flex-start;
    }

    .title-block h1 {
      margin: 0;
      font-size: 1.7rem;
      letter-spacing: 0.02em;
    }

    .subtitle {
      margin-top: 0.25rem;
      font-size: 0.9rem;
      color: var(--text-muted);
      max-width: 36rem;
    }

    .badge {
      display: inline-flex;
      align-items: center;
      gap: 0.25rem;
      padding: 0.15rem 0.6rem;
      border-radius: 999px;
      border: 1px solid rgba(59,130,246,0.4);
      background: rgba(37,99,235,0.1);
      color: #bfdbfe;
      font-size: 0.75rem;
      margin-top: 0.35rem;
    }

    .header-links {
      display: flex;
      gap: 0.4rem;
      align-items: center;
    }

    .header-links a {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 30px;
      height: 30px;
      border-radius: 999px;
      border: 1px solid var(--border-subtle);
      background: #020617;
      color: var(--text-main);
      text-decoration: none;
    }

    .header-links a:hover {
      border-color: var(--accent);
    }

    .header-links svg {
      width: 16px;
      height: 16px;
      fill: currentColor;
    }

    .input-card {
      background: var(--bg-card);
      border-radius: 0.75rem;
      border: 1px solid var(--border-subtle);
      padding: 1rem;
      margin-bottom: 1rem;
    }

    label {
      display: block;
      font-size: 0.85rem;
      margin-bottom: 0.35rem;
      color: var(--text-muted);
    }

    .url-row {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
    }

    #mcpUrl {
      flex: 1;
      min-width: 200px;
      padding: 0.55rem 0.7rem;
      border-radius: 0.5rem;
      border: 1px solid var(--border-subtle);
      background: #020617;
      color: var(--text-main);
      font-size: 0.9rem;
    }

    #mcpUrl::placeholder {
      color: #475569;
    }

    button {
      border-radius: 999px;
      border: none;
      padding: 0.55rem 1.1rem;
      cursor: pointer;
      background: var(--accent);
      color: #e5e7eb;
      font-size: 0.9rem;
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
      white-space: nowrap;
    }

    button:hover {
      background: #2563eb;
    }

    button:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }

    .copy-btn {
      border-radius: 999px;
      border: 1px solid var(--border-subtle);
      background: #020617;
      color: var(--text-main);
      width: 26px;
      height: 26px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      margin-left: 0.35rem;
      cursor: pointer;
    }

    .copy-btn.small {
      width: 22px;
      height: 22px;
    }

    .copy-btn:hover {
      border-color: var(--accent);
    }

    .copy-btn svg {
      width: 13px;
      height: 13px;
      fill: currentColor;
    }

    .hint {
      margin-top: 0.5rem;
      font-size: 0.8rem;
      color: var(--text-muted);
    }

    .hint code {
      background: var(--accent-soft);
      padding: 0.05rem 0.35rem;
      border-radius: 999px;
      font-size: 0.75rem;
    }

    .status {
      margin-top: 0.6rem;
      font-size: 0.8rem;
      color: var(--text-muted);
      white-space: pre-wrap;
    }

    .status.error {
      color: var(--danger);
    }

    .grid {
      display: grid;
      grid-template-columns: minmax(0, 2.2fr) minmax(0, 2.3fr);
      gap: 1rem;
      margin-top: 0.75rem;
    }

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

    .section {
      background: var(--bg-card);
      border-radius: 0.75rem;
      border: 1px solid var(--border-subtle);
      padding: 0.9rem;
      margin-bottom: 0.75rem;
    }

    .section h2 {
      margin: 0 0 0.45rem 0;
      font-size: 1rem;
      display: flex;
      align-items: center;
      gap: 0.35rem;
    }

    .section h2 span.dot {
      width: 6px;
      height: 6px;
      border-radius: 999px;
      background: var(--accent);
      display: inline-block;
    }

    .pill {
      display: inline-flex;
      align-items: center;
      gap: 0.25rem;
      padding: 0.1rem 0.5rem;
      border-radius: 999px;
      background: var(--accent-soft);
      color: var(--text-muted);
      font-size: 0.75rem;
      margin-bottom: 0.4rem;
    }

    .tool-card {
      border-radius: 0.6rem;
      border: 1px solid var(--border-subtle);
      padding: 0.6rem 0.7rem;
      margin-bottom: 0.6rem;
      background: radial-gradient(circle at top left, rgba(37,99,235,0.18) 0, transparent 40%);
    }

    .tool-name {
      font-size: 0.95rem;
      font-weight: 600;
      margin-bottom: 0.2rem;
    }

    .tool-desc {
      font-size: 0.85rem;
      color: var(--text-muted);
      margin-bottom: 0.3rem;
    }

    details {
      margin-top: 0.25rem;
      font-size: 0.8rem;
      color: var(--text-muted);
    }

    details summary {
      cursor: pointer;
      list-style: none;
    }

    details summary::-webkit-details-marker {
      display: none;
    }

    details summary::before {
      content: "▶ ";
      font-size: 0.7rem;
    }

    details[open] summary::before {
      content: "▼ ";
    }

    pre {
      background: #020617;
      padding: 0.5rem;
      border-radius: 0.5rem;
      overflow-x: auto;
      font-size: 0.75rem;
      line-height: 1.4;
      border: 1px solid var(--border-subtle);
      margin-top: 0.35rem;
      color: #e5e7eb;
    }

    .raw-json {
      max-height: 260px;
      overflow: auto;
    }

    /* Chat card */
    .chat-card small {
      color: var(--text-muted);
      display: block;
      margin-bottom: 0.5rem;
      font-size: 0.8rem;
    }

    .chat-layout {
      display: flex;
      flex-direction: column;
      gap: 0.6rem;
    }

    .key-row {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      align-items: center;
    }

    #apiKeyInput {
      flex: 1;
      min-width: 200px;
      padding: 0.45rem 0.7rem;
      border-radius: 0.5rem;
      border: 1px solid var(--border-subtle);
      background: #020617;
      color: var(--text-main);
      font-size: 0.85rem;
    }

    #apiKeyInput::placeholder {
      color: #475569;
    }

    .system-row {
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
      margin-top: 0.5rem;
      font-size: 0.8rem;
      color: var(--text-muted);
    }

    #systemPromptInput {
      width: 100%;
      min-height: 90px;
      max-height: 200px;
      resize: vertical;
      padding: 0.4rem 0.6rem;
      border-radius: 0.5rem;
      border: 1px solid var(--border-subtle);
      background: #020617;
      color: var(--text-main);
      font-size: 0.8rem;
      font-family: var(--font);
    }

    .chat-log {
      border-radius: 0.6rem;
      border: 1px solid var(--border-subtle);
      background: #020617;
      padding: 0.5rem;
      max-height: 240px;
      overflow-y: auto;
      font-size: 0.85rem;
    }

    .chat-message {
      margin-bottom: 0.35rem;
      display: flex;
    }

    .chat-message.user {
      justify-content: flex-end;
    }

    .chat-bubble {
      max-width: 80%;
      padding: 0.4rem 0.6rem;
      border-radius: 0.75rem;
      line-height: 1.4;
      white-space: pre-wrap;
    }

    .chat-message.user .chat-bubble {
      background: #1d4ed8;
      color: #e5e7eb;
      border-bottom-right-radius: 0.2rem;
    }

    .chat-message.assistant .chat-bubble {
      background: #0f172a;
      color: #e5e7eb;
      border-bottom-left-radius: 0.2rem;
    }

    .chat-input-row {
      display: flex;
      gap: 0.5rem;
      margin-top: 0.25rem;
    }

    #chatInput {
      flex: 1;
      min-height: 40px;
      max-height: 80px;
      resize: vertical;
      padding: 0.4rem 0.6rem;
      border-radius: 0.5rem;
      border: 1px solid var(--border-subtle);
      background: #020617;
      color: #e5e7eb;
      font-size: 0.85rem;
      font-family: var(--font);
    }

    .gh-inline-link {
      display: inline-flex;
      align-items: center;
      margin-left: 0.4rem;
      text-decoration: none;
      color: var(--accent);
      font-size: 0.8rem;
    }

    .gh-inline-link svg {
      width: 14px;
      height: 14px;
      fill: currentColor;
      margin-left: 2px;
    }

    .prompt-examples {
      margin-top: 0.35rem;
      font-size: 0.8rem;
      color: var(--text-muted);
    }

    .prompt-line {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 0.25rem;
      margin-top: 0.15rem;
    }

    .prompt-label {
      font-weight: 500;
      color: #cbd5f5;
      margin-right: 0.25rem;
    }

    footer {
      margin-top: 1.25rem;
      font-size: 0.75rem;
      color: var(--text-muted);
      display: flex;
      justify-content: space-between;
      gap: 0.5rem;
      flex-wrap: wrap;
    }

    footer a {
      color: var(--accent);
      text-decoration: none;
    }

    footer a:hover {
      text-decoration: underline;
    }
