:root {
  --ink: #181713;
  --paper: #f8f5ed;
  --panel: #fffdf7;
  --line: #d9d1bf;
  --muted: #746b5b;
  --accent: #0f766e;
  --accent-dark: #0b4f4b;
  --warn: #9a3412;
  --code: #20241f;
  --code-soft: #2d332c;
  --shadow: 0 22px 70px rgba(37, 32, 23, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(24, 23, 19, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(24, 23, 19, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
  font-family: Georgia, "Times New Roman", serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fffdf7;
  background: var(--ink);
  border-radius: 4px;
  font-size: 15px;
}

.nav-links {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 15px;
}

.nav-links a {
  text-decoration: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  align-items: end;
  gap: 44px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 34px 28px 24px;
}

.hero h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(58px, 9vw, 128px);
  line-height: 0.88;
  letter-spacing: 0;
}

.promise {
  max-width: 720px;
  margin: 28px 0 0;
  color: #39352d;
  font-size: 22px;
  line-height: 1.45;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-family: "Courier New", monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.specimen {
  position: relative;
  overflow: hidden;
  min-height: 250px;
  padding: 32px;
  color: #edf7ed;
  background: var(--code);
  border: 1px solid #11140f;
  box-shadow: var(--shadow);
}

.specimen::after {
  position: absolute;
  inset: auto -20px -34px auto;
  width: 180px;
  height: 180px;
  content: "";
  border: 1px solid rgba(237, 247, 237, 0.2);
  transform: rotate(12deg);
}

.specimen code {
  display: block;
  margin: 14px 0;
  font-family: "Courier New", monospace;
  font-size: 16px;
}

.specimen-rule {
  width: 100%;
  height: 8px;
  margin-bottom: 26px;
  background: repeating-linear-gradient(90deg, #c9b458 0 28px, transparent 28px 38px);
}

.tool-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 28px 32px;
}

.input-panel,
.output-panel,
.content-band,
.related-tools {
  background: rgba(255, 253, 247, 0.92);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(37, 32, 23, 0.08);
}

.input-panel,
.output-panel {
  min-width: 0;
  padding: 22px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.panel-heading h2,
.content-band h2,
.related-tools h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

button {
  min-height: 40px;
  padding: 10px 14px;
  color: #fffdf7;
  cursor: pointer;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 4px;
}

button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.icon-button {
  color: var(--ink);
  background: transparent;
}

.icon-button:hover,
.icon-button:focus-visible {
  color: #fffdf7;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.drop-zone {
  display: grid;
  min-height: 78px;
  margin-bottom: 14px;
  padding: 18px;
  place-items: center;
  color: var(--muted);
  text-align: center;
  border: 1px dashed #8e836e;
  background: #fbf8ef;
}

.drop-zone.dragging {
  color: var(--accent-dark);
  background: #eaf4f1;
  border-color: var(--accent);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

textarea {
  width: 100%;
  min-height: 330px;
  resize: vertical;
  padding: 18px;
  color: var(--code);
  background: #fffefa;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: "Courier New", monospace;
  font-size: 14px;
  line-height: 1.55;
}

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

.controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

select,
input[type="email"] {
  min-height: 42px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fffefa;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.toggle {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--ink) !important;
}

.toggle input {
  width: 18px;
  height: 18px;
}

.status {
  min-height: 24px;
  margin-bottom: 12px;
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 13px;
}

.status.error {
  color: var(--warn);
}

.rendered-preview {
  margin-bottom: 14px;
  padding: 14px;
  background: #fffefa;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.rendered-preview-heading {
  margin-bottom: 10px;
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.table-preview {
  overflow: auto;
}

.table-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.table-preview th,
.table-preview td {
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table-preview th {
  font-weight: 700;
  background: #f3eee1;
}

.table-preview .empty-preview {
  margin: 0;
  color: var(--muted);
}

.latex-output {
  overflow: auto;
  min-height: 404px;
  max-height: 560px;
  margin: 0;
  padding: 18px;
  color: #f2f2e8;
  background: var(--code-soft);
  border: 1px solid #171a16;
  border-radius: 4px;
  font-family: "Courier New", monospace;
  font-size: 14px;
  line-height: 1.55;
}

.upgrade-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 18px;
  background: #eaf4f1;
  border: 1px solid #9cc5bf;
}

.upgrade-panel h3,
.upgrade-panel p {
  margin: 0;
}

.upgrade-panel p {
  margin-top: 8px;
  color: #34514e;
}

.content-band,
.closing-band {
  max-width: 1184px;
  margin: 26px auto;
  padding: 28px;
}

.example-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.example-grid article {
  padding: 18px;
  border-left: 4px solid var(--accent);
  background: #fbf8ef;
}

.example-grid h3,
.example-grid p {
  margin: 0;
}

.example-grid p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.faq details {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.faq summary {
  cursor: pointer;
  font-size: 19px;
  font-weight: 700;
}

.faq p {
  max-width: 780px;
  color: var(--muted);
  line-height: 1.55;
}

.related-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 60px;
}

.closing-band h2 {
  width: 100%;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  padding: 20px;
  place-items: center;
  background: rgba(24, 23, 19, 0.58);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  width: min(540px, 100%);
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 36px;
  padding: 8px;
}

.modal-card form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.modal-card label {
  display: grid;
  gap: 6px;
}

@media (max-width: 900px) {
  .hero,
  .tool-shell {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: clamp(52px, 18vw, 86px);
  }

  .example-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    flex-wrap: wrap;
  }

  .hero,
  .tool-shell,
  .site-header {
    padding-right: 16px;
    padding-left: 16px;
  }

  .controls,
  .panel-heading,
  .upgrade-panel {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .button-row {
    justify-content: flex-start;
  }
}
