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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  background: #0d1117;
  color: #c9d1d9;
  min-height: 100vh;
}

/* Top nav */
.topnav {
  display: flex;
  justify-content: center;
  gap: 0;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topnav a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  color: #8b949e;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.topnav a:hover {
  color: #c9d1d9;
}

.topnav a.active {
  color: #f0f6fc;
  border-bottom-color: #58a6ff;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

h1 {
  font-size: 1.75rem;
  color: #f0f6fc;
  margin-bottom: 1.5rem;
  font-weight: 600;
}

h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b949e;
  margin-bottom: 0.75rem;
}

/* URL input */
.url-section {
  margin-bottom: 1.5rem;
}

.url-section label {
  display: block;
  font-size: 0.85rem;
  color: #8b949e;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.label-hint {
  text-transform: none;
  letter-spacing: normal;
  color: #484f58;
}

#url-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #f0f6fc;
  font-size: 0.95rem;
  font-family: "SF Mono", "Fira Code", monospace;
  outline: none;
  transition: border-color 0.15s;
  resize: vertical;
  line-height: 1.5;
}

#url-input:focus {
  border-color: #58a6ff;
}

/* Builder layout */
.builder {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

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

/* Palette */
.palette {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 1rem;
}

.palette-sub {
  margin-top: 1.25rem;
  border-top: 1px solid #30363d;
  padding-top: 1rem;
}

.palette-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.palette-buttons button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
  font-family: inherit;
}

.palette-buttons button:hover {
  background: #30363d;
  border-color: #58a6ff;
}

.cmd-icon {
  font-size: 1.1rem;
  width: 1.4rem;
  text-align: center;
}

/* Pipeline */
.pipeline {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 1rem;
  min-height: 200px;
}

.pipeline-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pipeline-empty {
  color: #484f58;
  font-size: 0.85rem;
  text-align: center;
  padding: 2rem 0;
}

/* Command block */
.cmd-block {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  transition: border-color 0.15s;
}

.cmd-block:hover {
  border-color: #58a6ff;
}

.cmd-drag {
  cursor: grab;
  color: #484f58;
  font-size: 1.1rem;
  user-select: none;
  padding: 0 0.15rem;
}

.cmd-drag:active {
  cursor: grabbing;
}

.cmd-drag.dragging {
  opacity: 0.4;
}

.cmd-block.drag-over {
  border-color: #58a6ff;
  background: #161b22;
}

.cmd-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #58a6ff;
  min-width: 7.5rem;
  text-transform: capitalize;
}

.cmd-params {
  display: flex;
  gap: 0.5rem;
  flex: 1;
}

.cmd-params input {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.55rem;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
  font-size: 0.82rem;
  font-family: "SF Mono", "Fira Code", monospace;
  outline: none;
}

.cmd-params input:focus {
  border-color: #58a6ff;
}

.cmd-params input::placeholder {
  color: #484f58;
}

.cmd-remove {
  background: none;
  border: none;
  color: #f85149;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  opacity: 0.6;
  transition:
    opacity 0.15s,
    background 0.15s;
}

.cmd-remove:hover {
  opacity: 1;
  background: rgba(248, 81, 73, 0.1);
}

/* Actions */
.actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.run-btn {
  padding: 0.65rem 1.75rem;
  background: #238636;
  border: 1px solid rgba(240, 246, 252, 0.1);
  border-radius: 6px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.run-btn:hover {
  background: #2ea043;
}

.run-btn:disabled {
  background: #21262d;
  color: #484f58;
  cursor: not-allowed;
}

.status {
  font-size: 0.85rem;
  color: #8b949e;
}

.status.loading {
  color: #58a6ff;
}

.status.error {
  color: #f85149;
}

.status.success {
  color: #3fb950;
}

/* Results */
.results {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  overflow: hidden;
}

.results.hidden {
  display: none;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #30363d;
}

.results-header h3 {
  margin: 0;
}

.results-actions {
  display: flex;
  gap: 0.5rem;
}

.results-list {
  display: flex;
  flex-direction: column;
}

.secondary-btn {
  padding: 0.4rem 0.85rem;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.secondary-btn:hover {
  background: #30363d;
}

/* Result card */
.result-card {
  border-bottom: 1px solid #30363d;
}

.result-card:last-child {
  border-bottom: none;
}

.result-card-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}

.result-card-header:hover {
  background: #161b22;
}

.result-chevron {
  font-size: 0.65rem;
  color: #8b949e;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.result-url {
  font-size: 0.85rem;
  font-family: "SF Mono", "Fira Code", monospace;
  color: #58a6ff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.result-card-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  margin-left: auto;
}

.result-error {
  padding: 0.5rem 1rem 0.75rem;
  font-size: 0.82rem;
  color: #f85149;
  font-family: "SF Mono", "Fira Code", monospace;
}

.result-card .html-output {
  border-top: 1px solid #30363d;
}

.html-output {
  padding: 1rem;
  max-height: 500px;
  overflow: auto;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #c9d1d9;
  white-space: pre-wrap;
  word-break: break-all;
  background: #0d1117;
  margin: 0;
}

/* Docs layout */
.docs-layout {
  display: flex;
  max-width: 960px;
  margin: 0 auto;
  min-height: calc(100vh - 45px);
}

.docs-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 25vh;
  height: 100vh;
  padding: 1.5rem 0;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  color: #8b949e;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition:
    color 0.15s,
    background 0.15s;
}

.sidebar-link:hover {
  color: #c9d1d9;
}

.sidebar-link.active {
  color: #f0f6fc;
  border-left: 2px solid #58a6ff;
}

.sidebar-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.docs-content {
  flex: 1;
  max-width: 700px;
  padding: 4rem 2.5rem;
}

/* Docs content */
.docs-content h1 {
  font-size: 1.5rem;
  color: #f0f6fc;
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #30363d;
}

.docs-content h1:first-of-type {
  margin-top: 0;
}

.docs-content h3 {
  font-size: 1rem;
  text-transform: none;
  letter-spacing: normal;
  color: #f0f6fc;
  margin: 1.75rem 0 0.5rem;
}

.docs-content p {
  font-size: 0.92rem;
  line-height: 1.65;
  margin-bottom: 0.75rem;
  color: #c9d1d9;
}

.docs-content ul {
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
  list-style-position: inside;
}

.docs-content li {
  font-size: 0.92rem;
  line-height: 1.65;
  margin-bottom: 0.35rem;
  color: #c9d1d9;
}

.docs-content code {
  background: #161b22;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #e3b341;
}

.docs-content a {
  color: #58a6ff;
  text-decoration: none;
}

.docs-content a:hover {
  text-decoration: underline;
}

.code-block {
  display: block;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 0.85rem 1rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: #c9d1d9;
  white-space: pre;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.88rem;
}

.docs-table th,
.docs-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: 1px solid #30363d;
}

.docs-table th {
  background: #161b22;
  color: #8b949e;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.docs-table td {
  background: #0d1117;
}

.docs-example {
  font-size: 0.88rem;
  color: #8b949e;
  margin-bottom: 1.5rem;
}

/* Extracted data */
.result-extracted {
  border-top: 1px solid #30363d;
  padding: 0.75rem 1rem;
}

.extracted-section {
  margin-bottom: 0.5rem;
}

.extracted-section:last-child {
  margin-bottom: 0;
}

.extracted-title {
  font-size: 0.78rem;
  color: #3fb950;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.extracted-values {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #c9d1d9;
  white-space: pre-wrap;
  margin: 0;
  max-height: 200px;
  overflow: auto;
}
