:root {
  color-scheme: dark;
  --bg: #050816;
  --panel: rgba(15, 23, 42, 0.82);
  --panel-strong: rgba(15, 23, 42, 0.96);
  --line: rgba(148, 163, 184, 0.2);
  --text: #edf5ff;
  --muted: #9fb0c7;
  --heading: #ffffff;
  --primary: #38bdf8;
  --primary-strong: #2dd4bf;
  --editor: #07101d;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f7fafc;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: #ffffff;
  --line: rgba(15, 23, 42, 0.13);
  --text: #172033;
  --muted: #64748b;
  --heading: #07111f;
  --primary: #0284c7;
  --primary-strong: #0f766e;
  --editor: #ffffff;
  --shadow: 0 22px 58px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(56, 189, 248, 0.22), transparent 30rem),
    radial-gradient(circle at 88% 4%, rgba(45, 212, 191, 0.18), transparent 26rem),
    linear-gradient(135deg, rgba(15, 23, 42, 0.2), transparent 45%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

button, textarea, select { font: inherit; }
textarea, pre, code { font-family: "JetBrains Mono", Consolas, "Courier New", monospace; }
a { color: inherit; text-decoration: none; }
p, h1, h2, h3, h4 { margin-top: 0; }

main {
  display: grid;
  gap: 16px;
}

.page-shell {
  position: relative;
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 34px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.nav, .nav-links, .hero-row, .hero-actions, .toolbar, .toolbar-actions, .editor-head, .editor-actions, .diff-nav, .diff-actions, .diff-side-action {
  display: flex;
  align-items: center;
}

.nav {
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: #04111f;
  background: linear-gradient(135deg, #7dd3fc, #34d399);
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.nav-links {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-links a, .theme-toggle, .btn, .file-label, .diff-action {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.nav-links a, .theme-toggle {
  padding: 10px 14px;
  font-size: 0.86rem;
}

.hero {
  padding-bottom: 6px;
}

.hero-row {
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0 8px;
}

.eyebrow, .section-kicker {
  margin-bottom: 8px;
  color: var(--primary);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

h1 {
  margin-bottom: 0;
  color: var(--heading);
  font-size: clamp(1.15rem, 2.2vw, 1.6rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.hero-actions, .toolbar-actions, .diff-nav, .diff-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-actions {
  justify-content: flex-end;
}

.action-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.action-group .btn,
.side-header-cell .btn {
  width: auto;
}

.btn, .diff-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 15px;
}

.btn-primary {
  border: 0;
  color: #04111f;
  background: linear-gradient(135deg, #7dd3fc, #34d399);
}

.btn-small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.diff-counter {
  min-width: 56px;
  color: var(--muted);
  text-align: center;
  font-size: 0.84rem;
  font-weight: 800;
}

.btn-secondary:hover, .nav-links a:hover, .theme-toggle:hover, .file-label:hover, .diff-action:hover {
  border-color: rgba(56, 189, 248, 0.55);
}

.workspace, .results, .seo-panel {
  margin-top: 16px;
  overflow: hidden;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.results {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 420px;
  max-height: calc(100vh - 110px);
}

.toolbar {
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.results .toolbar {
  position: sticky;
  top: 0;
  z-index: 4;
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
}

.toolbar h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.editor-panel {
  background: var(--panel-strong);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.editor-head {
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-strong);
}

.editor-head h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.editor-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.editor-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file-label {
  position: relative;
  padding: 9px 13px;
  font-size: 0.84rem;
  overflow: hidden;
}

.file-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

textarea {
  display: block;
  width: 100%;
  min-height: 320px;
  height: min(40vh, 520px);
  padding: 16px;
  border: 0;
  outline: 0;
  resize: vertical;
  color: var(--text);
  background: var(--editor);
  font-size: 0.9rem;
  line-height: 1.5;
  tab-size: 2;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.options-grid label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.9rem;
  font-weight: 700;
}

.options-grid label:has(select) {
  align-items: stretch;
  flex-direction: column;
  gap: 6px;
}

.options-grid span {
  color: var(--text);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

select {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-weight: 800;
}

option {
  color: #0f172a;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(7, 16, 29, 0.98), rgba(7, 16, 29, 0.92));
}

.stats-grid div {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.stats-grid strong {
  display: block;
  color: var(--heading);
  font-size: 1.2rem;
}

.stats-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.diff-output {
  min-height: 0;
  height: 100%;
  background: var(--editor);
  overflow: auto;
}

.empty-state {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--heading);
  font-size: 1.05rem;
}

.empty-state p {
  margin: 0 auto;
  max-width: 560px;
  line-height: 1.6;
}

.side-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
}

.side-header-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
}

.side-header-cell + .side-header-cell {
  border-left: 1px solid var(--line);
}

.side-header-cell span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.diff-row {
  display: grid;
  grid-template-columns: 64px 56px minmax(220px, 1fr) 56px minmax(220px, 1fr) 64px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.line-no {
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  text-align: right;
  user-select: none;
}

.diff-row pre, .unified-line pre {
  margin: 0;
  padding: 8px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.88rem;
  line-height: 1.45;
}

.diff-row pre:nth-child(2) {
  border-right: 1px solid var(--line);
}

.diff-row.added pre:last-of-type, .unified-line.added {
  background: rgba(34, 197, 94, 0.13);
}

.diff-row.removed pre:nth-child(2), .unified-line.removed {
  background: rgba(244, 63, 94, 0.14);
}

.diff-row.changed pre, .unified-group.changed .unified-line {
  background: rgba(250, 204, 21, 0.12);
}

.diff-actions {
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}

.diff-action {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.76rem;
  font-family: "JetBrains Mono", Consolas, "Courier New", monospace;
  letter-spacing: 0.02em;
}

.diff-side-action {
  justify-content: center;
  padding: 8px;
}

.diff-side-action.left {
  border-right: 1px solid var(--line);
}

.diff-side-action.right {
  border-left: 1px solid var(--line);
}

.diff-target.is-active {
  outline: 2px solid rgba(56, 189, 248, 0.75);
  outline-offset: -2px;
}

.token-add {
  border-radius: 4px;
  color: inherit;
  background: rgba(34, 197, 94, 0.34);
}

.token-remove {
  border-radius: 4px;
  color: inherit;
  background: rgba(244, 63, 94, 0.34);
}

.unified-diff {
  min-width: 760px;
}

.unified-group {
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.unified-line {
  display: grid;
  grid-template-columns: 38px 62px minmax(0, 1fr);
}

.unified-line span {
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  text-align: right;
  user-select: none;
}

.summary-panel {
  padding: 24px;
  max-width: 860px;
}

.summary-panel p, .summary-panel li {
  color: var(--muted);
  line-height: 1.65;
}

.seo-panel {
  padding: 22px;
}

.seo-intro {
  max-width: 980px;
}

.seo-panel h2 {
  margin-bottom: 10px;
}

.seo-panel p {
  color: var(--muted);
  line-height: 1.72;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.seo-grid article,
.faq-list details,
.content-columns article {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.seo-grid h3,
.content-columns h2 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.content-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.faq-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.faq-list summary {
  cursor: pointer;
  color: var(--heading);
  font-weight: 800;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: grid;
  gap: 10px;
}

.toast {
  max-width: 340px;
  padding: 13px 15px;
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 14px;
  color: var(--text);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  font-weight: 800;
}

.toast.error {
  border-color: rgba(251, 113, 133, 0.55);
}

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

  .options-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .results {
    max-height: none;
  }

  .seo-grid,
  .content-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .page-shell {
    width: min(100% - 20px, 1500px);
    padding-top: 10px;
  }

  .nav, .toolbar, .hero-row, .editor-head {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-links, .toolbar-actions, .hero-actions, .editor-actions {
    justify-content: flex-start;
  }

  .action-group {
    width: 100%;
    justify-content: space-between;
    border-radius: 16px;
  }

  .btn {
    width: 100%;
  }

  .btn-small, .diff-action {
    width: auto;
  }

  .stats-grid, .options-grid {
    grid-template-columns: 1fr;
  }

  .diff-row {
    grid-template-columns: 58px 44px minmax(160px, 1fr) 44px minmax(160px, 1fr) 58px;
  }

  .diff-actions {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }

  textarea {
    min-height: 260px;
    height: 320px;
  }
}
