:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #101828;
  --muted: #667085;
  --line: #d0d5dd;
  --soft: #f2f4f7;
  --accent: #157a6e;
  --accent-dark: #0f5e56;
  --blue: #2563eb;
  --focus: rgba(37, 99, 235, 0.24);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

button,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
  min-height: 68px;
  padding: 16px 24px;
}

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

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 7px;
  background: var(--text);
  color: white;
  font-size: 15px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 22px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.language-select {
  min-height: 38px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

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

.hero {
  max-width: 1180px;
  margin: 0 auto;
  padding: 44px 24px 40px;
}

.hero-copy {
  max-width: 780px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  font-size: clamp(42px, 5vw, 68px);
  line-height: 1.04;
  letter-spacing: 0;
}

.hero-copy p {
  margin-bottom: 32px;
  max-width: 720px;
  color: var(--muted);
  font-size: 19px;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.tool-links {
  display: grid;
  grid-template-columns: minmax(0, 720px);
  gap: 18px;
}

.tool-link {
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.tool-link:hover {
  border-color: #8bb4ad;
}

.tool-link-label {
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 800;
}

.tool-link strong {
  font-size: 24px;
  line-height: 1.15;
}

.tool-link em {
  color: var(--muted);
  font-size: 15px;
  font-style: normal;
}

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

.mini-tool-card {
  display: grid;
  gap: 8px;
  min-height: 148px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mini-tool-card:hover {
  border-color: #8bb4ad;
}

.mini-tool-card span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.mini-tool-card strong {
  font-size: 18px;
}

.mini-tool-card em {
  color: var(--muted);
  font-size: 14px;
  font-style: normal;
}

.single-tool {
  max-width: 720px;
}

.conversion-tool-shell {
  width: 100%;
}

.conversion-form {
  width: 100%;
}

.markdown-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.tool-panel {
  display: grid;
  gap: 16px;
  min-height: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.preview-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
  min-height: 100%;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.preview-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.preview-panel-header > div {
  min-width: 0;
}

.tool-panel h2 {
  margin-bottom: 6px;
  font-size: 22px;
  line-height: 1.18;
}

.tool-panel p,
.preview-panel p,
.format-note {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.markdown-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

.markdown-toolbar button,
.markdown-toolbar select {
  width: auto;
  min-width: 34px;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
}

.markdown-toolbar button {
  align-self: auto;
}

.markdown-toolbar button:hover {
  border-color: #8bb4ad;
  background: #eefaf7;
}

.markdown-toolbar select {
  min-width: 56px;
  cursor: pointer;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

input {
  min-height: 42px;
  padding: 9px 11px;
}

input[type="file"] {
  padding: 7px;
}

input[type="file"]::file-selector-button {
  min-height: 28px;
  margin-right: 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

textarea {
  min-height: 300px;
  padding: 12px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.markdown-preview {
  max-width: 100%;
  min-height: 420px;
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  font-family: "Arial Unicode MS", "Hiragino Sans GB", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Inter, ui-sans-serif, system-ui, sans-serif;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.markdown-workspace.has-content {
  grid-template-columns: minmax(320px, 0.42fr) minmax(0, 1fr);
}

.markdown-workspace.has-content .preview-panel {
  min-height: calc(100vh - 150px);
}

.markdown-workspace.has-content .markdown-preview {
  min-height: calc(100vh - 300px);
}

.print-title {
  display: none;
}

.markdown-preview h1 {
  margin: 0 0 16px;
  font-size: 34px;
  line-height: 1.1;
}

@media print {
  @page {
    margin: 18mm;
    size: A4;
  }

  body {
    background: #fff;
  }

  .site-header,
  .hero-copy,
  .tool-panel,
  .content-section,
  .site-footer,
  .preview-panel-header {
    display: none !important;
  }

  .hero,
  .markdown-workspace,
  .preview-panel {
    display: block;
    width: 720px;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .print-title {
    display: none;
  }

  .markdown-preview {
    min-height: auto !important;
    overflow: visible;
    border: 0;
    background: #fff;
  }
}

.markdown-preview h2 {
  margin: 24px 0 10px;
  font-size: 24px;
}

.markdown-preview h3 {
  margin: 20px 0 8px;
  font-size: 18px;
}

.markdown-preview p,
.markdown-preview li,
.markdown-preview td,
.markdown-preview th,
.markdown-preview blockquote {
  color: var(--text);
  font-size: 16px;
}

.markdown-preview ul {
  padding-left: 22px;
}

.markdown-preview pre {
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.markdown-preview .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

.markdown-preview .mermaid-diagram {
  display: grid;
  place-items: center;
  overflow-x: auto;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.markdown-preview .mermaid-diagram svg {
  max-width: 100%;
  height: auto;
}

.markdown-preview .mermaid-error {
  border-color: #fca5a5;
}

.markdown-preview code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

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

.markdown-preview th,
.markdown-preview td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.markdown-preview th {
  background: #eaf0f6;
  font-weight: 800;
}

.markdown-preview blockquote {
  margin: 18px 0;
  padding: 2px 0 2px 16px;
  border-left: 4px solid #8bb4ad;
  color: var(--muted);
}

.markdown-preview img {
  max-width: 100%;
  height: auto;
}

.markdown-preview a {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.markdown-preview hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 28px 0;
}

.markdown-preview .task-list-item {
  list-style: none;
  margin-left: -20px;
}

.markdown-preview .task-list-item input {
  width: auto;
  min-height: 0;
  margin-right: 8px;
}

.empty-preview {
  color: var(--muted) !important;
}

.dropzone,
.upload-zone {
  min-height: 168px;
  align-content: center;
  padding: 22px;
  border: 1px dashed #9fb0c3;
  border-radius: 8px;
  background: var(--soft);
}

.upload-zone {
  position: relative;
  display: grid;
  gap: 10px;
  min-height: 240px;
  place-items: center;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.upload-zone:hover,
.upload-zone.is-drag-over {
  border-color: var(--accent);
  background: #eefaf7;
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.12);
}

.upload-zone-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-zone-kicker {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.upload-zone strong {
  font-size: 24px;
  line-height: 1.1;
}

.upload-zone em {
  color: var(--muted);
  font-size: 15px;
  font-style: normal;
}

.upload-zone-file {
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.url-source {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.url-source span {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.url-source em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.image-preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.image-preview img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
}

.compression-result {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  gap: 18px;
  align-items: center;
  padding: 20px;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  background: #ecfdf5;
}

.compression-result[hidden] {
  display: none;
}

.compression-result.is-increase {
  border-color: #fed7aa;
  background: #fff7ed;
}

.compression-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.compression-result strong {
  display: block;
  color: var(--text);
  font-size: clamp(28px, 5vw, 48px);
  line-height: 1;
}

.compression-result dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.compression-result dl > div {
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.7);
}

.compression-result dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.compression-result dd {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.conversion-status {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.conversion-status.is-error {
  color: #b42318;
}

button {
  align-self: end;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-size: 15px;
  font-weight: 760;
  cursor: pointer;
}

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

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.primary-download {
  display: grid;
  gap: 2px;
  justify-items: center;
  align-self: start;
  min-width: 180px;
  min-height: 52px;
  background: var(--blue);
  box-shadow: 0 14px 32px rgba(37, 99, 235, 0.24);
}

.primary-download:hover {
  background: #1d4ed8;
}

.primary-download span {
  font-size: 17px;
}

.primary-download small {
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 650;
}

.content-section {
  max-width: 1180px;
  margin: 0 auto;
  padding: 54px 24px;
  border-top: 1px solid var(--line);
}

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

.section-heading h2,
.content-section h2 {
  margin-bottom: 8px;
  font-size: 32px;
  line-height: 1.1;
}

.section-heading p,
.content-section p {
  color: var(--muted);
}

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

.steps article {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.steps span {
  display: grid;
  width: 30px;
  height: 30px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 999px;
  background: #dff7f3;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.steps h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 28px;
  align-items: start;
}

.limits-list {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.limits-list p {
  margin-bottom: 10px;
}

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

.faq-preview summary {
  cursor: pointer;
  font-weight: 760;
}

.readable {
  max-width: 820px;
}

.site-footer {
  display: flex;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 44px;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
}

.site-footer span {
  margin-right: auto;
  color: var(--text);
  font-weight: 760;
}

/* Workspace layout */
.tool-markdown .hero {
  max-width: 1440px;
  padding-top: 24px;
}

.tool-markdown .hero-copy {
  max-width: 860px;
  margin-bottom: 24px;
}

.tool-markdown h1 {
  margin-bottom: 10px;
  font-size: clamp(32px, 3.4vw, 48px);
  line-height: 1.08;
}

.tool-markdown .hero-copy p {
  max-width: 780px;
  margin-bottom: 0;
  font-size: 16px;
}

.tool-markdown .markdown-workspace {
  gap: 0;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.06);
  overflow: hidden;
}

.tool-markdown .markdown-workspace.has-content {
  grid-template-columns: minmax(340px, 0.43fr) minmax(0, 0.57fr);
}

.tool-markdown .tool-panel,
.tool-markdown .preview-panel {
  min-width: 0;
  padding: 20px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.tool-markdown .tool-panel {
  align-content: start;
  border-right: 1px solid var(--line);
  background: #fcfcfd;
}

.tool-markdown .preview-panel {
  grid-template-rows: auto minmax(520px, 1fr);
  background: var(--surface);
}

.tool-markdown .tool-panel h2,
.tool-markdown .preview-panel h2 {
  margin-bottom: 4px;
  font-size: 16px;
  font-weight: 760;
}

.tool-markdown .tool-panel p,
.tool-markdown .preview-panel p {
  font-size: 13px;
  line-height: 1.5;
}

.markdown-toolbar {
  gap: 4px;
  padding: 6px;
  border-radius: 6px;
  background: var(--soft);
}

.markdown-toolbar button,
.markdown-toolbar select {
  display: grid;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  place-items: center;
  border-color: transparent;
  border-radius: 5px;
  background: transparent;
}

.markdown-toolbar button:hover {
  border-color: #b9c7d7;
  background: var(--surface);
}

.markdown-toolbar button:active {
  background: #e7eef8;
}

.markdown-toolbar button svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.markdown-toolbar select {
  width: 58px;
  min-width: 58px;
  padding: 0 4px;
  border-color: var(--line);
  background: var(--surface);
  font-size: 12px;
  font-weight: 750;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  margin: 7px 3px;
  background: var(--line);
}

.markdown-source-label {
  gap: 8px;
}

.tool-markdown textarea {
  min-height: 540px;
  padding: 14px;
  border-color: var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 14px;
  line-height: 1.6;
}

.tool-markdown input[type="text"] {
  min-height: 40px;
}

.tool-markdown input[type="file"] {
  min-height: 40px;
  border-color: var(--line);
  background: var(--surface);
}

.preview-panel-header {
  position: sticky;
  top: 8px;
  z-index: 1;
  align-items: center;
  padding: 4px 0 14px;
  background: var(--surface);
}

.primary-download {
  grid-template-columns: 1fr;
  gap: 2px;
  min-width: 176px;
  min-height: 56px;
  padding: 8px 14px;
  border: 1px solid #1d4ed8;
  border-radius: 6px;
  box-shadow: none;
}

.primary-download span {
  font-size: 15px;
}

.primary-download small {
  text-align: center;
  font-size: 11px;
  line-height: 1.2;
}

.markdown-preview {
  min-height: 520px;
  padding: clamp(24px, 4vw, 56px);
  border-color: #e4e7ec;
  border-radius: 6px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(16, 24, 40, 0.01);
}

.markdown-workspace.has-content .preview-panel,
.markdown-workspace.has-content .markdown-preview {
  min-height: 620px;
}

.markdown-preview h1 {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 34px;
}

.markdown-preview h2 {
  margin-top: 34px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eaecf0;
}

.markdown-preview pre {
  border-radius: 6px;
  background: #f8fafc;
}

.markdown-preview th {
  background: #f2f4f7;
}

.tool-markdown .content-section {
  max-width: 1440px;
  padding-top: 40px;
  padding-bottom: 40px;
}

.tool-markdown .mini-tool-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tool-markdown .mini-tool-card,
.tool-markdown .steps article,
.tool-markdown .limits-list {
  box-shadow: none;
}

@media (prefers-reduced-motion: no-preference) {
  a,
  button,
  input,
  select,
  textarea,
  .mini-tool-card,
  .tool-link {
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
  }
}

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

  .nav {
    gap: 12px;
  }

  .preview-panel-header {
    flex-direction: column;
  }

  .primary-download {
    width: 100%;
  }

  .hero {
    padding-top: 32px;
  }

  h1 {
    font-size: 42px;
  }

  .tool-grid,
  .tool-links,
  .mini-tool-grid,
  .markdown-workspace,
  .markdown-workspace.has-content,
  .compression-result,
  .steps,
  .split {
    grid-template-columns: 1fr;
  }

  .compression-result dl {
    grid-template-columns: 1fr;
  }

  .markdown-workspace.has-content .preview-panel,
  .markdown-workspace.has-content .markdown-preview {
    min-height: 600px;
  }
}

@media (max-width: 820px) {
  .site-header {
    gap: 14px;
    padding: 14px 20px;
  }

  .nav {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    gap: 10px 18px;
  }

  .language-select {
    flex-basis: 170px;
  }

  .tool-markdown .hero {
    padding: 20px 16px 28px;
  }

  .tool-markdown .hero-copy {
    margin-bottom: 20px;
  }

  .tool-markdown h1 {
    font-size: 32px;
  }

  .tool-markdown .markdown-workspace,
  .tool-markdown .markdown-workspace.has-content {
    border-radius: 0;
    border-right: 0;
    border-left: 0;
    box-shadow: none;
  }

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

  .tool-markdown .tool-panel,
  .tool-markdown .preview-panel {
    padding: 16px;
  }

  .tool-markdown textarea {
    min-height: 420px;
  }

  .markdown-toolbar {
    gap: 5px;
  }

  .toolbar-divider {
    display: none;
  }

  .preview-panel-header {
    position: static;
    align-items: stretch;
  }

  .primary-download {
    width: 100%;
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .markdown-preview,
  .markdown-workspace.has-content .markdown-preview {
    min-height: 460px;
    padding: 24px 18px;
  }

  .markdown-preview h1 {
    font-size: 28px;
  }

  .tool-markdown .mini-tool-grid {
    grid-template-columns: 1fr;
  }
}
