:root {
  --ink: #151a22;
  --muted: #596474;
  --soft: #f7f8fa;
  --surface: #ffffff;
  --line: #d9dee6;
  --line-strong: #c0c8d3;
  --green: #248a3d;
  --green-soft: #eaf7ed;
  --amber: #b96e13;
  --amber-soft: #fff6e7;
  --blue: #2265d8;
  --shadow: 0 16px 38px rgba(27, 36, 49, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: #fbfbfc;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

body.is-contrast {
  --ink: #f7fbff;
  --muted: #c4d0dd;
  --soft: #121820;
  --surface: #0d131b;
  --line: #2c3948;
  --line-strong: #455568;
  background: #080d13;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto auto;
  gap: 22px;
  align-items: center;
  min-height: 64px;
  padding: 10px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

body.is-contrast .site-header {
  background: rgba(13, 19, 27, 0.94);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
}

.main-nav {
  display: flex;
  gap: 28px;
  color: var(--muted);
  font-weight: 650;
}

.main-nav a:hover {
  color: var(--green);
}

.contrast-toggle,
.icon-button,
.ghost-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}

.contrast-toggle,
.icon-button {
  display: grid;
  width: 38px;
  height: 36px;
  place-items: center;
}

.page-shell {
  width: min(1460px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.intro {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.intro h1 {
  margin: 0 0 10px;
  font-size: 46px;
  line-height: 1.05;
}

.intro p {
  max-width: 820px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.converter {
  display: grid;
  grid-template-columns: minmax(380px, 0.92fr) minmax(520px, 1.08fr);
  gap: 20px;
  align-items: stretch;
}

.workspace-panel,
.info-section,
.faq-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workspace-panel {
  padding: 16px;
}

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

h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

h2 span {
  display: inline-grid;
  width: 23px;
  height: 23px;
  margin-right: 8px;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 12px;
}

.dropzone {
  position: relative;
  display: grid;
  min-height: 205px;
  margin-top: 14px;
  place-items: center;
  padding: 24px;
  border: 2px dashed var(--green);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(248, 251, 248, 0.98), rgba(255, 255, 255, 0.98));
  text-align: center;
}

body.is-contrast .dropzone {
  background: #111922;
}

.dropzone.is-dragging {
  outline: 3px solid rgba(36, 138, 61, 0.16);
  background: var(--green-soft);
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.file-icon {
  display: grid;
  width: 58px;
  height: 70px;
  margin-bottom: 10px;
  place-items: end center;
  padding-bottom: 12px;
  border: 2px solid var(--line-strong);
  border-radius: 7px 14px 7px 7px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.dropzone p {
  margin: 4px 0;
  color: var(--muted);
}

.dropzone strong {
  color: var(--ink);
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 7px;
  font-weight: 800;
}

.primary-button {
  margin-top: 10px;
  border: 0;
  background: var(--green);
  color: #fff;
}

.secondary-button {
  border: 1px solid var(--green);
  background: var(--surface);
  color: var(--green);
}

.secondary-button:disabled {
  cursor: not-allowed;
  border-color: var(--line-strong);
  color: #8792a0;
}

.file-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto 34px;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  margin: 12px 0 18px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.doc-icon {
  display: grid;
  width: 34px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--muted);
}

.file-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #bfe8c8;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.status-pill.muted {
  border-color: var(--line);
  background: var(--soft);
  color: var(--muted);
}

.status-pill.warning {
  border-color: #f1cf98;
  background: var(--amber-soft);
  color: var(--amber);
}

.settings {
  display: grid;
  gap: 13px;
}

.settings label {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  color: var(--ink);
  font-weight: 700;
}

.settings select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}

.switch-row {
  grid-template-columns: minmax(0, 1fr) auto !important;
}

.switch-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 500;
}

.switch-row input {
  width: 44px;
  height: 23px;
  accent-color: var(--green);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.preview-heading,
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-heading small {
  color: var(--muted);
  font-weight: 600;
}

.preview-toolbar {
  justify-content: flex-start;
  margin: 14px -16px 0;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  font-weight: 750;
}

.preview-body {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  min-height: 438px;
}

.toc-panel {
  padding: 18px 16px 18px 0;
  border-right: 1px solid var(--line);
}

.toc-panel h3 {
  margin: 0 0 12px;
  font-size: 14px;
}

.toc-panel ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
}

.paper-wrap {
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  background: linear-gradient(180deg, var(--soft), rgba(255, 255, 255, 0));
}

body.is-contrast .paper-wrap {
  background: #101720;
}

.paper {
  width: min(420px, 100%);
  min-height: 500px;
  padding: 54px 48px;
  border: 1px solid var(--line);
  background: #fff;
  color: #161616;
  box-shadow: 0 18px 34px rgba(18, 24, 32, 0.12);
  transform-origin: center top;
}

.paper-kicker {
  margin: 0 0 24px;
  color: #667085;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.paper h3 {
  margin: 0 0 20px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 500;
  text-align: center;
}

.paper p {
  color: #333;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  line-height: 1.75;
}

.paper-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  margin-top: 24px;
  color: #444;
  font-size: 12px;
}

.paper-meta dt {
  font-weight: 800;
}

.paper-meta dd {
  margin: 0;
}

.review-note {
  margin: 0 -16px -16px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.info-section,
.faq-section {
  padding: 22px;
}

.info-section p,
.faq-answer p,
.steps,
.checklist {
  color: var(--muted);
  line-height: 1.65;
}

.steps,
.checklist {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding-left: 22px;
}

.example-table {
  display: grid;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

.example-row:first-child {
  border-top: 0;
}

.example-row span {
  padding: 11px 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.example-head span {
  background: var(--soft);
  color: var(--ink);
  font-weight: 800;
}

.faq-section {
  margin-top: 20px;
}

.faq-list {
  display: grid;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.faq-item {
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  font-weight: 800;
}

.faq-item:first-child {
  border-top: 0;
}

.faq-item::after {
  content: "+";
  float: right;
  color: var(--green);
}

.faq-item[aria-expanded="true"]::after {
  content: "−";
}

.faq-answer {
  display: none;
  padding: 0 18px 16px;
  border-top: 1px solid var(--line);
}

.faq-answer.is-open {
  display: block;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(340px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(34, 101, 216, 0.35);
  outline-offset: 2px;
}

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

  .preview-body {
    min-height: 360px;
  }
}

@media (max-width: 720px) {
  .site-header {
    grid-template-columns: 1fr auto;
    padding: 10px 16px;
  }

  .main-nav {
    grid-column: 1 / -1;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
  }

  .page-shell {
    width: min(100vw - 24px, 680px);
    padding-top: 20px;
  }

  .intro h1 {
    font-size: 34px;
  }

  .intro p {
    font-size: 15px;
  }

  .settings label,
  .switch-row,
  .file-row,
  .preview-body,
  .example-row {
    grid-template-columns: 1fr;
  }

  .file-row {
    align-items: start;
  }

  .toc-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-right: 0;
  }

  .paper-wrap {
    padding: 14px;
  }

  .paper {
    min-height: 390px;
    padding: 36px 24px;
  }

  .actions,
  .preview-toolbar {
    align-items: stretch;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }
}
