:root {
  color-scheme: light;
  --bg: #f3f5f1;
  --paper: #fffefa;
  --panel: #ffffff;
  --ink: #20231f;
  --muted: #687064;
  --quiet: #8a9286;
  --line: #d9ded3;
  --line-strong: #c8d0c1;
  --green: #1f6b4f;
  --green-dark: #124a36;
  --gold: #c98c2c;
  --red: #a84432;
  --code-bg: #fbfcf8;
  --code-ink: #263024;
  --header-bg: rgba(255, 254, 250, 0.9);
  --page-glow: rgba(255, 254, 250, 0.9);
  --button-bg: #ffffff;
  --shadow: 0 24px 70px rgba(48, 55, 46, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101412;
  --paper: #161b18;
  --panel: #1a201d;
  --ink: #eef3eb;
  --muted: #aab4a7;
  --quiet: #858f83;
  --line: #2b342f;
  --line-strong: #3a463f;
  --green: #62c79d;
  --green-dark: #96e4c0;
  --gold: #e2ad5d;
  --red: #ef907d;
  --code-bg: #121714;
  --code-ink: #e7eee5;
  --header-bg: rgba(16, 20, 18, 0.9);
  --page-glow: rgba(35, 45, 39, 0.82);
  --button-bg: #202722;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top left, var(--page-glow), transparent 430px),
    linear-gradient(180deg, var(--page-glow), transparent 440px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(217, 222, 211, 0.82);
  background: var(--header-bg);
  backdrop-filter: blur(18px);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1240px, calc(100% - 32px));
  min-height: 64px;
  margin: 0 auto;
  gap: 24px;
}

.brand,
.nav-links,
.nav-actions,
.privacy-pill,
.control-strip,
.control-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-size: 0.98rem;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(31, 107, 79, 0.24);
  border-radius: 8px;
  background: color-mix(in srgb, var(--green) 12%, var(--paper));
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 900;
}

.nav-actions {
  gap: 12px;
}

.nav-links {
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.nav-links a {
  border-radius: 8px;
  padding: 8px 10px;
}

.nav-links a:hover {
  background: color-mix(in srgb, var(--green) 10%, transparent);
  color: var(--green-dark);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border-color: var(--line);
  background: var(--button-bg);
  color: var(--ink);
  padding: 0 11px;
}

.theme-toggle:hover {
  border-color: var(--green);
  color: var(--green-dark);
}

.theme-icon {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset -4px -2px 0 currentColor;
}

:root[data-theme="dark"] .theme-icon {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 12%, transparent);
}

main {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
}

.app-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: end;
  padding: 42px 0 22px;
}

.intro-copy {
  max-width: 860px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2.15rem, 5vw, 4.65rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  font-size: 1rem;
}

.intro-copy p:not(.eyebrow) {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.68;
}

.intro-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.jump-link,
.text-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border-radius: 8px;
  font-weight: 850;
}

.jump-link {
  background: var(--green);
  color: #fff;
  padding: 0 16px;
}

.jump-link:hover {
  background: var(--green-dark);
}

:root[data-theme="dark"] .jump-link {
  color: #0b1510;
}

.text-link {
  color: var(--green-dark);
  padding: 0 4px;
}

.privacy-pill {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 330px;
}

.privacy-pill span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  padding: 9px 12px;
  color: var(--green-dark);
  font-size: 0.84rem;
  font-weight: 850;
}

.workspace {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.control-strip {
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 74%, var(--bg));
  padding: 14px;
}

.control-group {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.control-group label {
  color: var(--quiet);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

select {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--ink);
  padding: 0 34px 0 12px;
  font-weight: 760;
}

.control-actions {
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 850;
}

.primary-button {
  background: var(--green);
  color: #fff;
}

.primary-button:hover {
  background: var(--green-dark);
}

:root[data-theme="dark"] .primary-button {
  color: #0b1510;
}

.secondary-button {
  border-color: var(--line-strong);
  background: var(--button-bg);
  color: var(--ink);
}

.secondary-button:hover {
  border-color: var(--green);
  color: var(--green-dark);
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 500px;
}

.editor-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  background: var(--code-bg);
}

.editor-panel:first-child {
  border-right: 1px solid var(--line);
}

.output-panel {
  background: color-mix(in srgb, var(--code-bg) 80%, var(--gold) 5%);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
}

.panel-header h2 {
  font-size: 0.98rem;
}

.panel-header span {
  color: var(--quiet);
  font-size: 0.78rem;
  font-weight: 750;
}

textarea {
  width: 100%;
  min-height: 448px;
  resize: vertical;
  border: 0;
  outline: 0;
  padding: 18px;
  background: transparent;
  color: var(--code-ink);
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 0.91rem;
  line-height: 1.58;
}

textarea::placeholder {
  color: #92998d;
}

.review-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr;
  border-right: 1px solid var(--line);
}

.metric-row div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
}

.metric-row div + div {
  border-top: 1px solid var(--line);
}

.metric-row strong {
  color: var(--green-dark);
  font-size: 1.55rem;
  line-height: 1;
}

.metric-row span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.detected-card {
  min-width: 0;
  padding: 16px;
}

.detected-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.detected-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.detected-list {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}

.detected-item {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
  font-size: 0.86rem;
}

.badge {
  width: fit-content;
  border-radius: 999px;
  background: color-mix(in srgb, var(--gold) 18%, transparent);
  color: var(--gold);
  padding: 5px 8px;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.detected-value,
.replacement-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

.replacement-value {
  color: var(--green-dark);
  font-weight: 850;
}

.empty-state {
  margin: 0;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.explain-grid,
.privacy-section,
.faq-section {
  padding: 62px 0;
}

.explain-grid {
  display: grid;
  grid-template-columns: 1.2fr repeat(3, 1fr);
  gap: 18px;
}

.section-heading {
  max-width: 330px;
}

.section-heading h2,
.privacy-section h2 {
  font-size: clamp(1.6rem, 2.8vw, 2.6rem);
  line-height: 1.04;
}

.explain-grid article {
  border-top: 2px solid var(--line-strong);
  padding-top: 16px;
}

.step {
  display: inline-block;
  margin-bottom: 22px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 950;
}

.explain-grid p,
.privacy-copy p,
.faq-section p {
  color: var(--muted);
  line-height: 1.66;
}

.privacy-section {
  display: grid;
  grid-template-columns: minmax(280px, 0.75fr) minmax(0, 1.25fr);
  gap: 44px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.privacy-copy {
  display: grid;
  gap: 12px;
}

.privacy-copy p {
  margin: 0;
  font-size: 1.02rem;
}

.faq-section {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.faq-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.faq-card h3 {
  font-weight: 900;
}

.faq-card p {
  margin: 12px 0 0;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 26px 16px;
  color: var(--muted);
  text-align: center;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 1020px) {
  .app-intro,
  .explain-grid,
  .privacy-section,
  .faq-section {
    grid-template-columns: 1fr;
  }

  .privacy-pill {
    justify-content: flex-start;
    max-width: none;
  }

  .section-heading {
    max-width: 680px;
  }
}

@media (max-width: 820px) {
  .nav {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 0;
  }

  .nav-actions,
  .nav-links {
    width: 100%;
    justify-content: space-between;
  }

  .control-strip,
  .control-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .control-actions,
  .control-group,
  button,
  select {
    width: 100%;
  }

  .editor-grid,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .editor-panel:first-child,
  .metric-row {
    border-right: 0;
  }

  .editor-panel:first-child {
    border-bottom: 1px solid var(--line);
  }

  .metric-row {
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid var(--line);
  }

  .metric-row div {
    display: grid;
    justify-items: center;
    padding: 14px 10px;
  }

  .metric-row div + div {
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  textarea {
    min-height: 300px;
  }
}

@media (max-width: 560px) {
  main,
  .nav {
    width: min(100% - 24px, 1240px);
  }

  .app-intro {
    padding-top: 30px;
  }

  h1 {
    font-size: 2.2rem;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
    height: auto;
    padding: 12px 14px;
  }

  .metric-row,
  .detected-item {
    grid-template-columns: 1fr;
  }

  .metric-row div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
