:root {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1a2335;
  --border: #263248;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #ff6d5a;
  --accent-hover: #ff8575;
  --indigo: #818cf8;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(11, 17, 32, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
}

.brand:hover {
  text-decoration: none;
}

.brand-badge {
  font-size: 0.72rem;
  font-family: var(--mono);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.14);
  color: var(--green);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Hero */
.hero {
  padding: 28px 0 18px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 2.8vw, 2.15rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  color: var(--text-muted);
  max-width: 78ch;
  font-size: 0.96rem;
}

.preset-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.preset-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-right: 4px;
}

.pill-btn, .pill-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.84rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.pill-btn:hover, .pill-link:hover {
  border-color: var(--indigo);
  text-decoration: none;
}

.pill-btn.active, .pill-link.active {
  background: rgba(255, 109, 90, 0.14);
  border-color: var(--accent);
  color: #ffd5cf;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin: 18px 0 20px;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 10px 16px;
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Grid & Cards */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 650;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

textarea, input[type="text"], select {
  width: 100%;
  background: #070c18;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.45;
}

textarea:focus, input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--indigo);
}

textarea.code-editor {
  min-height: 220px;
  resize: vertical;
}

textarea.expr-input {
  min-height: 92px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1120;
}

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

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

/* Output Box */
.output-box {
  background: #070c18;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 0.86rem;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 82px;
  max-height: 300px;
  overflow: auto;
}

.output-box.error {
  border-color: rgba(248, 113, 113, 0.55);
  color: var(--red);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.74rem;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge.ok {
  color: var(--green);
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.1);
}

.badge.warn {
  color: var(--amber);
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.1);
}

.badge.err {
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.1);
}

/* JSON Tree Explorer */
.tree-list {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #070c18;
}

.tree-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid rgba(38, 50, 72, 0.55);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.tree-row:last-child {
  border-bottom: none;
}

.tree-key {
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-val {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-left: 8px;
}

.tree-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  font-family: var(--mono);
  font-size: 0.76rem;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: #cbd5e1;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--indigo);
  color: #fff;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.82rem;
}

th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}

th {
  background: #070c18;
  color: var(--text-muted);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

.dst-row {
  background: rgba(251, 191, 36, 0.08);
}

/* Assignments builder */
.assignment-row {
  display: grid;
  grid-template-columns: 1fr 110px 2fr auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

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

/* Affiliate CTA Section */
.cta-section {
  margin: 30px 0;
}

.cta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

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

.cta-card {
  background: linear-gradient(180deg, rgba(26, 35, 53, 0.9), rgba(17, 24, 39, 0.95));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.cta-card h3 {
  margin: 4px 0 6px;
  font-size: 1rem;
}

.cta-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* SEO Guide Content */
.seo-section {
  margin: 26px 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.seo-section h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

.seo-section ul {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--text-muted);
}

.seo-section li {
  margin-bottom: 6px;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 36px;
  padding: 22px 0 36px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 10px;
}

.inline-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #0f172a;
  color: var(--green);
  border: 1px solid var(--green);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: var(--mono);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 50;
}

.toast.visible {
  opacity: 1;
}
