/* ============================================
   TOKENS
   ============================================ */
:root {
  --ink: #1A1B1E;
  --ink-soft: #3A3C42;
  --paper: #FAF9F6;
  --paper-raised: #FFFFFF;
  --signal: #2D5BFF;
  --signal-dim: #E8EDFF;
  --slate: #6B7280;
  --slate-light: #9CA0A8;
  --hairline: #E4E2DC;
  --hairline-strong: #D2CFC6;
  --success: #1E8E5A;
  --warn: #C2750C;
  --danger: #C7401F;

  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Inter', -apple-system, sans-serif;

  --radius-sm: 3px;
  --radius-md: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--signal); color: white; }

a { color: inherit; }

/* faint engineering grid behind everything */
.grid-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(to right, rgba(26,27,30,0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(26,27,30,0.025) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* ============================================
   TOP BAR
   ============================================ */
.top-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--hairline);
  background: var(--paper);
}

.top-bar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-bar__mark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  color: var(--paper);
  background: var(--ink);
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  letter-spacing: -0.5px;
}

.top-bar__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.top-bar__title {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.top-bar__sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--slate);
  margin-top: 2px;
}

.top-bar__status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--slate);
  border: 1px solid var(--hairline);
  padding: 6px 12px;
  border-radius: 100px;
  background: var(--paper-raised);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--slate-light);
  transition: background 0.2s ease;
}

.top-bar__status.is-ready { color: var(--success); border-color: #BFE3D2; }
.top-bar__status.is-ready .status-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(30,142,90,0.15); }

/* ============================================
   WORKBENCH LAYOUT
   ============================================ */
.workbench {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}

.panel { min-width: 0; }

.form-panel {
  padding: 32px;
  border-right: 1px solid var(--hairline);
}

.preview-panel {
  padding: 32px;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.field-group {
  margin-bottom: 36px;
}

.field-group__label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
}

.field-group__index {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--paper);
  background: var(--ink);
  padding: 2px 6px;
  border-radius: 3px;
}

.field-group__label h2 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.field-group__hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--slate-light);
  margin-left: auto;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field-row .field { margin-bottom: 0; }

.field__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.field__name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.field__name em {
  font-style: normal;
  font-weight: 400;
  color: var(--slate-light);
  font-size: 11px;
}

.field__count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--slate-light);
  font-variant-numeric: tabular-nums;
}

.field__count.is-warn { color: var(--warn); }
.field__count.is-danger { color: var(--danger); }

.field__sub {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--slate-light);
  margin-top: 5px;
}

input[type="text"],
input[type="url"],
textarea,
select {
  width: 100%;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  resize: vertical;
  font-family: var(--sans);
  line-height: 1.45;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-dim);
}

input::placeholder, textarea::placeholder { color: var(--slate-light); }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.field__meter {
  display: block;
  height: 3px;
  background: var(--hairline);
  border-radius: 2px;
  margin-top: 7px;
  overflow: hidden;
}

.field__meter-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--signal);
  border-radius: 2px;
  transition: width 0.15s ease, background 0.15s ease;
}

.field__meter-fill.is-warn { background: var(--warn); }
.field__meter-fill.is-danger { background: var(--danger); }

.swatch-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

input[type="color"] {
  width: 38px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  flex-shrink: 0;
}

.field--swatch .swatch-row input[type="text"] {
  font-family: var(--mono);
  text-transform: uppercase;
}

/* ============================================
   PREVIEW BLOCKS
   ============================================ */
.preview-block__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--slate);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.preview-block__label--row {
  justify-content: space-between;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot--google { background: #4285F4; }
.dot--social { background: #1877F2; }
.dot--code { background: var(--ink); }

/* --- Google SERP card --- */
.serp-card {
  background: var(--paper-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  font-family: arial, sans-serif;
}

.serp-card__url-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.serp-card__favicon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--hairline);
  color: var(--slate);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  flex-shrink: 0;
}

.serp-card__url-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.serp-card__site {
  font-size: 13px;
  color: #202124;
}

.serp-card__path {
  font-size: 12px;
  color: #5f6368;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.serp-card__title {
  font-size: 19px;
  color: #1a0dab;
  line-height: 1.3;
  margin: 2px 0 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.serp-card__desc {
  font-size: 13.5px;
  color: #4d5156;
  line-height: 1.55;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* --- Social card --- */
.social-card {
  background: var(--paper-raised);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-family: Helvetica, Arial, sans-serif;
  max-width: 440px;
}

.social-card__image {
  width: 100%;
  aspect-ratio: 1200 / 630;
  background: linear-gradient(135deg, #EEF1F8 0%, #E4E8F4 100%);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--hairline);
}

.social-card__image-placeholder {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--slate-light);
  letter-spacing: 0.04em;
}

.social-card__body {
  padding: 11px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.social-card__domain {
  font-size: 11px;
  letter-spacing: 0.03em;
  color: #65676B;
}

.social-card__title {
  font-size: 14.5px;
  font-weight: 700;
  color: #050505;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.social-card__desc {
  font-size: 12.5px;
  color: #65676B;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* --- Code output --- */
.copy-btn {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--paper);
  background: var(--ink);
  border: none;
  border-radius: 100px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.copy-btn:hover { background: var(--signal); }
.copy-btn:active { transform: scale(0.97); }
.copy-btn.is-copied { background: var(--success); }

.code-output {
  background: var(--ink);
  color: #D4D4D8;
  border-radius: var(--radius-md);
  padding: 18px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  overflow-x: auto;
  margin: 0;
  max-height: 420px;
  overflow-y: auto;
}

.code-output code {
  font-family: var(--mono);
  white-space: pre;
}

.preview-block--code { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* simple syntax tint via spans inserted by JS */
.tok-tag { color: #7DA6FF; }
.tok-attr { color: #9CDCFE; }
.tok-val { color: #CE9178; }
.tok-comment { color: #6A6E76; font-style: italic; }

/* ============================================
   FOOTER
   ============================================ */
.bottom-note {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 22px 32px 36px;
  border-top: 1px solid var(--hairline);
  max-width: 1400px;
  margin: 0 auto;
}

.bottom-note p {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--slate-light);
  margin: 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 880px) {
  .workbench { grid-template-columns: 1fr; }
  .form-panel { border-right: none; border-bottom: 1px solid var(--hairline); }
  .preview-panel { position: static; max-height: none; }
  .field-row { grid-template-columns: 1fr; }
  .top-bar { padding: 14px 18px; flex-wrap: wrap; gap: 10px; }
  .form-panel, .preview-panel { padding: 22px 18px; }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

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