:root {
  --brand: #165dff;
  --brand-dark: #0e42d2;
  --green: #00a870;
  --red: #e34d59;
  --orange: #ed7b2f;
  --ink: #1d2129;
  --text: #4e5969;
  --muted: #86909c;
  --line: #e5e6eb;
  --soft: #f5f7fb;
  --blue-soft: #edf4ff;
  --panel: #ffffff;
  --shadow: 0 18px 50px rgba(29, 33, 41, 0.08);
  --radius: 8px;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }

body { margin: 0; min-height: 100vh; color: var(--ink); background: #f5f7fb; }

button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }

.app-header {
  position: sticky; top: 0; z-index: 20;
  min-height: 54px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 0 clamp(16px, 4vw, 46px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  min-width: max-content;
  font-size: 20px; font-weight: 850;
}
.logo { width: 30px; height: 30px; display: block; border-radius: 7px; object-fit: contain; }

.top-nav, .header-actions, .row-actions {
  display: flex; align-items: center; gap: 8px;
}
.top-nav { justify-content: center; min-width: 0; }

.nav-btn, .icon-btn, .primary-btn, .secondary-btn, .ghost-btn, .danger-btn {
  min-height: 36px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 13px;
  border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--text); white-space: nowrap;
}

.nav-btn:hover, .nav-btn.active { color: var(--brand); background: var(--blue-soft); }

.icon-btn { width: 36px; padding: 0; }
.icon-btn:hover { background: #f2f3f5; }

.primary-btn {
  min-height: 38px; padding: 0 16px;
  color: #fff; border-color: var(--brand); background: var(--brand);
}
.primary-btn:hover { background: var(--brand-dark); }
.primary-btn:disabled {
  color: #fff; border-color: #b8c7ff; background: #b8c7ff; cursor: not-allowed;
}

.secondary-btn { border-color: #d9e3f5; background: #fff; color: var(--ink); }
.secondary-btn:hover { border-color: var(--brand); color: var(--brand); }

.ghost-btn { color: var(--brand); }
.danger-btn { color: var(--red); background: #fff0ed; }

.tool-icon { width: 18px; height: 18px; display: inline-block; position: relative; flex: none; }

.tool-icon.mail { border: 1.6px solid currentColor; border-radius: 3px; }
.tool-icon.mail::before, .tool-icon.mail::after {
  content: ""; position: absolute; top: 4px; width: 10px; height: 1.5px; background: currentColor;
}
.tool-icon.mail::before { left: 1px; transform: rotate(34deg); }
.tool-icon.mail::after { right: 1px; transform: rotate(-34deg); }

.tool-icon.upload::before, .tool-icon.upload::after,
.tool-icon.download::before, .tool-icon.close::before, .tool-icon.close::after {
  content: ""; position: absolute; background: currentColor;
}

.tool-icon.upload::before { left: 8px; top: 2px; width: 2px; height: 12px; }
.tool-icon.upload::after {
  left: 3px; top: 2px; width: 12px; height: 12px;
  clip-path: polygon(50% 0, 100% 46%, 68% 46%, 68% 100%, 32% 100%, 32% 46%, 0 46%);
}

.tool-icon.download::before { left: 8px; top: 2px; width: 2px; height: 12px; }
.tool-icon.download::after {
  content: ""; position: absolute;
  left: 3px; top: 8px; width: 12px; height: 12px;
  background: currentColor;
  clip-path: polygon(32% 0, 68% 0, 68% 54%, 100% 54%, 50% 100%, 0 54%, 32% 54%);
}

.tool-icon.close::before, .tool-icon.close::after {
  left: 8px; top: 2px; width: 2px; height: 15px;
}
.tool-icon.close::before { transform: rotate(45deg); }
.tool-icon.close::after { transform: rotate(-45deg); }

.page {
  max-width: 1320px; margin: 0 auto;
  padding: 14px clamp(16px, 3vw, 32px) 22px;
  display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 14px;
}

.card {
  border: 1px solid #e8edf7; border-radius: var(--radius);
  background: #fff; box-shadow: 0 10px 30px rgba(29, 33, 41, 0.04);
}

.side { align-self: start; padding: 14px; }
.side-section + .side-section { margin-top: 16px; padding-top: 14px; border-top: 1px solid #edf1f8; }
.side-title { margin: 4px 8px 12px; color: var(--muted); font-size: 13px; font-weight: 750; }

.tool-list { display: grid; gap: 6px; }
.tool-btn {
  min-height: 42px;
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 0 10px;
  border: 0; border-radius: 7px;
  background: transparent; color: var(--text); text-align: left;
}
.tool-btn:hover, .tool-btn.active { color: var(--brand); background: var(--blue-soft); }

.mini-doc {
  width: 22px; height: 22px;
  display: grid; place-items: center; border-radius: 5px;
  background: #fff0ed; color: var(--red);
  font-size: 9px; font-weight: 850;
}
.mini-doc.blue { background: var(--blue-soft); color: var(--brand); }
.mini-doc.green { background: #e8f8f2; color: var(--green); }
.mini-doc.orange { background: #fff3e8; color: var(--orange); }

.main { display: grid; gap: 12px; min-width: 0; }

.converter { overflow: hidden; box-shadow: var(--shadow); }
.converter-head {
  min-height: 60px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid #edf1f8;
}

.title-group { display: flex; align-items: center; gap: 12px; min-width: 0; }

.doc-icon {
  width: 38px; height: 38px;
  display: grid; place-items: center; flex: none;
  border-radius: 8px;
  background: #fff0ed; color: var(--red);
  font-size: 11px; font-weight: 900;
}
.doc-icon.blue { background: var(--blue-soft); color: var(--brand); }
.doc-icon.green { background: #e8f8f2; color: var(--green); }
.doc-icon.orange { background: #fff3e8; color: var(--orange); }

h1 { margin: 0; font-size: 20px; line-height: 1.2; }
.sub { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.format-tabs { display: flex; gap: 8px; overflow-x: auto; }
.format-tab {
  min-height: 34px; padding: 0 12px;
  border: 1px solid #dce5f6; border-radius: 7px;
  background: #fff; color: var(--text); white-space: nowrap;
}
.format-tab:hover, .format-tab.active { color: var(--brand); border-color: var(--brand); background: var(--blue-soft); }

.converter-body { padding: 16px 18px; }

.drop {
  min-height: 190px;
  display: grid; place-items: center;
  padding: 18px;
  border: 1.5px dashed #b8c7ff; border-radius: var(--radius);
  background: linear-gradient(180deg, #fbfdff, #ffffff);
  text-align: center; transition: 0.18s ease;
}
.drop.dragover { border-color: var(--brand); background: var(--blue-soft); }

.drop-visual {
  width: 64px; height: 48px; margin: 0 auto 10px;
  position: relative; border-radius: 14px;
  background: var(--blue-soft); color: var(--brand);
}
.drop-visual::before, .drop-visual::after {
  content: ""; position: absolute; border-radius: 50%; background: var(--blue-soft);
}
.drop-visual::before { width: 30px; height: 30px; top: -13px; left: 10px; }
.drop-visual::after { width: 36px; height: 36px; top: -17px; right: 8px; }
.drop-visual i { position: absolute; z-index: 1; left: 23px; top: 16px; }

.drop h2 { margin: 0; font-size: 18px; }
.drop p { margin: 6px 0 12px; color: var(--muted); font-size: 13px; }

.limit-note { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.drop-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.file-card {
  display: none;
  gap: 12px; align-items: center;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  min-height: 92px; padding: 12px 14px;
  border: 1px solid #edf1f8; border-radius: var(--radius);
  background: #fbfdff;
}
.file-card.show { display: grid; }

.file-name { font-weight: 750; word-break: break-all; }
.file-meta { margin-top: 5px; color: var(--muted); font-size: 13px; }

.progress {
  height: 8px; margin-top: 10px;
  border-radius: 999px; background: #edf1f8;
  overflow: hidden;
}
.progress i {
  display: block; width: 0; height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--green));
  transition: width 0.22s ease;
}

.progress-stages { display: none; margin-top: 10px; }
.progress-stages.show { display: grid; gap: 10px; }
.progress-stage .progress { margin-top: 0; }
.progress-stage-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 4px;
  color: var(--muted); font-size: 13px;
}
.progress-stage-head b { color: var(--brand); font-weight: 800; }
.progress-stage.done .progress-stage-head b { color: var(--green); }
.progress-stage.done .progress-stage-head b::before { content: "✓ "; }
.progress-stage.pending .progress i { background: #cbd5e1; }

.status {
  min-height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 10px; border-radius: 999px;
  background: #f2f3f5; color: var(--text);
  font-size: 13px; white-space: nowrap;
}
.status.working { background: var(--blue-soft); color: var(--brand); }
.status.done { background: #e8f8f2; color: #078d5c; }
.status.error { background: #fff0ed; color: var(--red); }

.controls {
  display: flex; align-items: center; justify-content: flex-end; gap: 14px;
  margin-top: 12px; flex-wrap: wrap;
}
.row-actions { display: flex; align-items: center; gap: 8px; }

.converter.success .file-card { border-color: #bcebdc; background: #fbfffd; }
.converter.error .file-card { border-color: #ffd8d2; background: #fffafa; }

.footer {
  max-width: 1320px; margin: 0 auto;
  padding: 0 clamp(16px, 3vw, 32px) 18px;
  color: var(--muted); font-size: 12px;
}
.footer-inner {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  flex-wrap: wrap;
  min-height: 40px;
  border-top: 1px solid #e8edf7;
}

.toast {
  position: fixed; right: 22px; top: 78px; z-index: 60;
  min-width: 230px; max-width: min(380px, calc(100vw - 32px));
  padding: 12px 14px; border-radius: 8px;
  background: #1d2129; color: #fff; font-size: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
  opacity: 0; transform: translateY(-8px); pointer-events: none;
  transition: 0.2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(16, 24, 40, 0.46);
}
.modal-backdrop.show { display: flex; }

.modal {
  width: min(560px, 100%);
  max-height: min(680px, calc(100vh - 40px));
  overflow: auto;
  border-radius: 8px; background: #fff;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.26);
}
.modal-head, .modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #edf1f8;
}
.modal-foot { justify-content: flex-end; border-top: 1px solid #edf1f8; border-bottom: 0; }
.modal h3 { margin: 0; font-size: 19px; }
.modal-body { padding: 18px; color: var(--text); line-height: 1.8; }
.modal-body p { margin: 0 0 12px; }

input[type="file"] { display: none; }

/* SEO blocks below the converter — FAQ + related tools */
.seo-card { padding: 18px 20px; }
.seo-h2 { margin: 0 0 12px; font-size: 18px; }

.faq-list { display: grid; gap: 8px; }
.faq-item {
  padding: 10px 14px;
  border: 1px solid #edf1f8; border-radius: 7px;
  background: #fbfdff;
}
.faq-item[open] { background: #fff; border-color: #dce5f6; }
.faq-q {
  cursor: pointer; list-style: none;
  color: var(--ink); font-weight: 700; font-size: 14px; line-height: 1.55;
}
.faq-q::-webkit-details-marker { display: none; }
.faq-q::after {
  content: "+"; float: right;
  color: var(--muted); font-size: 18px; font-weight: 400; line-height: 1;
  transition: transform 0.18s ease;
}
.faq-item[open] .faq-q::after { content: "−"; }
.faq-a {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid #edf1f8;
  color: var(--text); font-size: 14px; line-height: 1.7;
}

.related-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.related-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border: 1px solid #edf1f8; border-radius: 7px;
  background: #fbfdff; color: inherit;
  text-decoration: none; transition: 0.15s ease;
}
.related-card:hover {
  border-color: var(--brand); background: var(--blue-soft);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 93, 255, 0.08);
}
.related-card .doc-icon { width: 36px; height: 36px; font-size: 11px; flex: none; }
.related-title { color: var(--ink); font-weight: 750; font-size: 14px; }
.related-sub { margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.5; }

/* contact / api-docs static pages */
.contact-list { display: grid; gap: 12px; margin: 14px 0 22px; }
.contact-row {
  display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 12px; align-items: center;
  padding: 10px 14px;
  border: 1px solid #edf1f8; border-radius: 7px;
  background: #fbfdff;
}
.contact-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.contact-value { color: var(--ink); word-break: break-all; }

.qrcode-wrap { margin: 18px auto 0; max-width: 240px; text-align: center; }
.qrcode-img { display: block; margin: 0 auto; border-radius: 8px; }
.qrcode-placeholder {
  display: grid; place-items: center; gap: 6px;
  width: 220px; height: 220px; margin: 0 auto;
  border: 2px dashed #dce5f6; border-radius: 8px;
  background: #fbfdff; color: var(--muted);
  text-align: center;
}
.qrcode-placeholder span { font-size: 14px; font-weight: 750; color: var(--text); }
.qrcode-placeholder small { font-size: 12px; }

.api-card {
  margin: 12px 0; padding: 14px 16px;
  border: 1px solid #edf1f8; border-radius: 7px;
  background: #fbfdff;
}
.api-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; font-size: 15px; }
.api-card p { margin: 6px 0 8px; color: var(--text); font-size: 14px; }
.badge {
  padding: 1px 9px; border-radius: 999px;
  background: var(--blue-soft); color: var(--brand);
  font-size: 12px; font-weight: 750;
}
.api-list { margin: 6px 0 0; padding-left: 20px; line-height: 1.85; color: var(--text); }
.api-list code, .code-block code {
  padding: 1px 6px; border-radius: 4px;
  background: #eef2fb; color: #1d2129;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace; font-size: 13px;
}
.code-block {
  margin: 8px 0 0; padding: 14px 16px;
  border: 1px solid #edf1f8; border-radius: 7px;
  background: #0f172a; color: #e2e8f0;
  overflow-x: auto;
}
.code-block code { background: transparent; color: inherit; padding: 0; }

/* history records */
.history-section { margin-top: 18px; }
.history-title { font-size: 16px; font-weight: 750; margin: 0 0 10px; color: var(--text); }
.history-list { display: grid; gap: 8px; }
.history-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 14px;
  border: 1px solid #edf1f8; border-radius: 7px;
  background: #fbfdff;
}
.history-name { font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.history-action {
  padding: 4px 12px; border-radius: 5px; border: none;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.history-action:hover { background: #3060e0; }
.history-action:disabled { background: #b0c4de; cursor: default; }
.history-clear {
  margin-top: 8px; padding: 0; border: none; background: none;
  color: var(--muted); font-size: 12px; cursor: pointer; text-decoration: underline;
}
.history-clear:hover { color: var(--text); }

@media (max-width: 1160px) { .page { grid-template-columns: 210px minmax(0, 1fr); } }

@media (min-width: 1440px) {
  .page, .footer { max-width: 1440px; }
  .drop { min-height: 230px; }
}

@media (max-width: 900px) {
  .app-header, .converter-head {
    align-items: flex-start; flex-direction: column;
    padding-top: 14px; padding-bottom: 14px;
  }
  .top-nav { width: 100%; justify-content: flex-start; overflow-x: auto; }
  .header-actions { width: 100%; justify-content: flex-end; }
  .page { grid-template-columns: 1fr; padding-top: 16px; }
  .side { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .side-section + .side-section { margin-top: 0; padding-top: 0; border-top: 0; }
  .tool-list { grid-template-columns: 1fr; }
  .converter-head { gap: 14px; }
  .format-tabs { width: 100%; padding-bottom: 2px; }
  .steps { align-items: flex-start; flex-direction: column; }
  .step-line {
    width: 1px; height: 18px; margin: 2px 13px;
    border-top: 0; border-left: 1.5px dashed #b8c7ff;
  }
}

@media (max-width: 620px) {
  .app-header { gap: 12px; padding-left: 14px; padding-right: 14px; }
  .brand { font-size: 18px; }
  .top-nav { padding-bottom: 2px; }
  .page { padding: 12px 12px 28px; gap: 12px; }
  .side { display: block; padding: 12px; }
  .side-section { min-width: 0; }
  .side-section + .side-section { margin-top: 12px; padding-top: 12px; border-top: 1px solid #edf1f8; }
  .tool-list { display: flex; overflow-x: auto; padding-bottom: 2px; scroll-snap-type: x proximity; }
  .tool-btn { width: auto; min-width: 138px; scroll-snap-align: start; }
  .converter-head, .converter-body { padding: 16px; }
  h1 { font-size: 22px; }
  .sub { font-size: 13px; }
  .drop { min-height: 250px; padding: 24px 16px; }
  .drop h2 { font-size: 20px; }
  .drop p { font-size: 14px; }
  .format-tabs { width: 100%; }
  .file-card { grid-template-columns: 48px minmax(0, 1fr); }
  .file-card .status { grid-column: 1 / -1; justify-self: start; }
  .controls, .row-actions, .drop-actions { align-items: stretch; flex-direction: column; }
  .row-actions, .row-actions button, .drop-actions button { width: 100%; }
  .policy { align-items: flex-start; line-height: 1.55; }
  .footer { padding-left: 12px; padding-right: 12px; }
}

@media (max-width: 420px) {
  .header-actions { justify-content: flex-start; }
  .nav-btn, .primary-btn, .secondary-btn, .ghost-btn {
    min-height: 38px; padding-left: 11px; padding-right: 11px;
  }
  .doc-icon { width: 38px; height: 38px; font-size: 11px; }
  .file-card { gap: 12px; padding: 14px; }
  .progress-stage-head { font-size: 12px; }
  .modal-backdrop { padding: 10px; }
  .modal-head, .modal-foot, .modal-body { padding-left: 14px; padding-right: 14px; }
}
