/* ==========================================================================
   DWG DXF to Image（Web 版）样式表
   单文件、零外部依赖：不引用 CDN 字体或框架，避免渲染阻塞与隐私合规问题。
   ========================================================================== */

/* ----- Reset（仅保留本项目用到的部分） ----- */
html { line-height: 1.5; -webkit-text-size-adjust: 100%; }
h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}
button, [type="button"], [type="reset"], [type="submit"] {
  -webkit-appearance: button;
  background-color: transparent;
  background-image: none;
}
button, [role="button"], summary, a { cursor: pointer; }
img, svg, canvas { display: block; vertical-align: middle; }
img, video { max-width: 100%; height: auto; }
* { box-sizing: border-box; }

/* ----- Design tokens ----- */
:root {
  --primary-1: #6366F1;
  --primary-2: #8B5CF6;
  --primary-3: #3B82F6;
  --bg-1: #F5F7FB;
  --bg-2: #FFFFFF;
  --bg-3: #EEF2FF;
  --text-1: #1F2937;
  --text-2: #6B7280;
  --ok: #10B981;
  --err: #EF4444;
  --warn: #F59E0B;
  --line: rgba(99, 102, 241, 0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px -12px rgba(99, 102, 241, 0.35);
  --shadow-soft: 0 4px 16px -6px rgba(31, 41, 55, 0.18);
  --gradient: linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #3B82F6 100%);
  --tap: 40px; /* 触控目标最小边长 */
}

html, body { margin: 0; padding: 0; }
body {
  min-height: 100dvh; /* 移动端地址栏收起时也会铺满 */
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-1);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(139, 92, 246, 0.10), transparent 60%),
    radial-gradient(1000px 500px at -10% 110%, rgba(59, 130, 246, 0.10), transparent 60%),
    var(--bg-1);
}

/* ----- 顶栏 ----- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 10px;
  background: var(--gradient);
  display: grid; place-items: center;
  color: #fff;
  box-shadow: var(--shadow);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 600; font-size: 15px; line-height: 1.25; }
.brand-tag {
  font-size: 12px; color: var(--text-2); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 46vw;
}
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ----- 语言菜单（<details>：点击展开，触屏可用） ----- */
.lang-menu { position: relative; }
.lang-menu > summary {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-2);
  list-style: none;
  touch-action: manipulation;
}
.lang-menu > summary::-webkit-details-marker { display: none; }
.lang-menu > summary .caret { font-size: 11px; color: var(--text-2); }
.lang-menu[open] > summary { color: var(--primary-1); border-color: rgba(99, 102, 241, 0.4); }
.lang-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 168px;
  /* 13 种语言：菜单必须能在小屏内滚动，否则会顶出视口 */
  max-height: min(70dvh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px -18px rgba(31, 41, 55, 0.5);
  z-index: 60;
}
.lang-list a {
  display: flex; align-items: center;
  min-height: var(--tap);
  padding: 0 12px;
  border-radius: 8px;
  color: var(--text-1);
  text-decoration: none;
  font-size: 13.5px;
  touch-action: manipulation;
}
.lang-list a:hover { background: var(--bg-3); color: var(--primary-1); }
.lang-list a.active { background: var(--bg-3); color: var(--primary-1); font-weight: 600; }

/* ----- 主体 ----- */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 20px max(28px, env(safe-area-inset-bottom));
}
.hero { margin-bottom: 18px; }
.hero-title { font-size: 22px; line-height: 1.35; letter-spacing: 0.2px; }
.hero-sub { margin-top: 6px; color: var(--text-2); font-size: 14px; }

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

/* ----- 卡片 ----- */
.card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px;
}
.card-title {
  font-size: 14px; font-weight: 600;
  color: var(--text-1);
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.card-title::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gradient);
}

/* ----- 拖放区 ----- */
.dropzone {
  border: 1.5px dashed rgba(99, 102, 241, 0.35);
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.04);
  padding: 20px 16px;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
  touch-action: manipulation;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary-1); background: rgba(99, 102, 241, 0.1); }
.dz-big { font-size: 15px; font-weight: 600; }
.dz-hint { color: var(--text-2); font-size: 13px; margin-top: 6px; }
.dz-actions { margin-top: 14px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ----- 表单 ----- */
.field { margin-top: 16px; }
.field > label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 7px; font-weight: 500; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.input {
  width: 100%;
  min-height: var(--tap);
  padding: 9px 12px;
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-1);
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus { border-color: var(--primary-1); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15); }
.inline-mini { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--text-2); }
.inline-mini b { color: var(--primary-1); }

.seg { display: flex; gap: 4px; padding: 4px; background: #fff; border: 1px solid rgba(99, 102, 241, 0.22); border-radius: var(--radius-sm); }
.seg button {
  flex: 1;
  min-height: 32px;
  border: 0; border-radius: 7px;
  padding: 8px 6px;
  background: transparent;
  font-size: 13px; font-weight: 500;
  color: #374151;
  transition: all .18s ease;
  touch-action: manipulation;
}
.seg button:hover { background: rgba(99, 102, 241, 0.08); color: #4F46E5; }
.seg button.active { background: var(--primary-1); color: #fff; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; margin: 8px 0 2px;
  border-radius: 999px;
  background: var(--gradient);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary-1);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary-1);
}

/* ----- 文件列表 ----- */
.files { margin-top: 4px; max-height: 300px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.files .empty { color: var(--text-2); font-size: 13px; padding: 10px 2px; }
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.file-item.is-active { border-color: var(--primary-1); box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.14); }
.file-item .nm { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .meta { flex: 0 0 auto; color: var(--text-2); font-size: 12px; white-space: nowrap; }
.file-item .btn { flex: 0 0 auto; text-decoration: none; }

.badge {
  flex: 0 0 auto;
  font-size: 11px; padding: 4px 9px; border-radius: 999px;
  background: var(--bg-3); color: var(--primary-1); white-space: nowrap;
}
.badge-ok { background: #ECFDF5; color: var(--ok); }
.badge-err { background: #FEF2F2; color: var(--err); }
.badge-warn { background: #FFFBEB; color: var(--warn); }

/* ----- 按钮 ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  transition: box-shadow .25s ease, transform .18s ease, opacity .2s ease;
  touch-action: manipulation;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { box-shadow: 0 14px 34px -10px rgba(99, 102, 241, 0.55); }
.btn-ghost { background: #fff; color: var(--primary-1); border-color: rgba(99, 102, 241, 0.28); }
.btn-ghost:hover { background: var(--bg-3); }
.btn-sm { min-height: 32px; padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.actions { margin-top: 12px; display: flex; gap: 10px; }

/* ----- 预览 ----- */
.preview-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f7f8fc;
  min-height: 190px;
  max-height: 380px;
  display: grid;
  place-items: center;
  padding: 10px;
  overflow: auto;
}
.preview-box .empty { color: var(--text-2); font-size: 13px; }
.preview-box img { max-width: 100%; max-height: 320px; border-radius: 6px; }
.preview-meta { margin-top: 8px; font-size: 12px; color: var(--text-2); text-align: center; }
/* 透明底预览用棋盘格表示 Alpha */
.preview-box.checker {
  background-image:
    linear-gradient(45deg, #dfe3ee 25%, transparent 25%),
    linear-gradient(-45deg, #dfe3ee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfe3ee 75%),
    linear-gradient(-45deg, transparent 75%, #dfe3ee 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

/* ----- 进度 ----- */
.progress { display: none; margin-top: 12px; }
.progress.show { display: block; }
.bar { height: 8px; border-radius: 999px; background: var(--bg-3); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--gradient); transition: width .25s ease; }
.progress .txt { margin-top: 6px; font-size: 12px; color: var(--text-2); }

/* ----- 提示 ----- */
.tip {
  margin-top: 14px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-2);
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.tip-privacy { margin-top: 6px; color: var(--primary-1); }

/* ----- noscript ----- */
.noscript {
  margin: 16px auto;
  max-width: 640px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #FFFBEB;
  color: #92400E;
  font-size: 13px;
}

/* ----- Toast ----- */
#toast-host {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
#toast-host .toast {
  background: #fff;
  border-left: 4px solid var(--primary-1);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13.5px;
  min-width: 200px;
  max-width: min(360px, 86vw);
  box-shadow: 0 14px 34px -10px rgba(31, 41, 55, 0.35);
  opacity: 0;
  transform: translateX(24px);
  transition: opacity .3s ease, transform .3s ease;
}
#toast-host .toast-show { opacity: 1; transform: none; }
#toast-host .toast-success { border-left-color: var(--ok); }
#toast-host .toast-error { border-left-color: var(--err); }

/* ----- Modal ----- */
#modal-root .modal-overlay {
  position: fixed; inset: 0; z-index: 150;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(31, 41, 55, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
#modal-root .modal-hide { opacity: 0; transition: opacity .16s ease; }
#modal-root .modal-box {
  width: 440px;
  max-width: 100%;
  max-height: calc(100dvh - 48px);
  overflow: auto;
  padding: 22px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 30px 60px -20px rgba(31, 41, 55, 0.5);
}
#modal-root .modal-title { font-size: 17px; font-weight: 600; margin-bottom: 14px; }
#modal-root .modal-body { font-size: 14px; line-height: 1.7; }
#modal-root .modal-msg { white-space: pre-wrap; word-break: break-word; }
#modal-root .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ==========================================================================
   响应式
   ========================================================================== */

/* 中等屏：两栏，结果卡片占满一行 */
@media (max-width: 1180px) {
  .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid > .card:last-child { grid-column: 1 / -1; }
}

/* 窄屏（手机 / 竖屏平板）：单栏堆叠，顶栏允许换行 */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: 10px 14px; }
  .brand-tag { max-width: 70vw; }
  .main { padding: 16px 14px max(24px, env(safe-area-inset-bottom)); }
  .grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .grid > .card:last-child { grid-column: auto; }
  .hero-title { font-size: 19px; }
  .files { max-height: 240px; }
  .preview-box { max-height: 300px; }
  .preview-box img { max-height: 240px; }
}

/* 小屏：次要文案收窄，控件铺满 */
@media (max-width: 640px) {
  .brand-tag { display: none; }
  .top-actions .btn-sm { padding: 6px 10px; }
  .dz-actions .btn { flex: 1 1 auto; }
  .row2 { grid-template-columns: 1fr; }
  /* 语言菜单按内容宽度展开，但不超出视口（右侧已对齐按钮右缘） */
  .lang-list { min-width: 0; width: max-content; max-width: calc(100vw - 24px); }
  .file-item { flex-wrap: wrap; }
  .file-item .meta { order: 3; width: 100%; }
}

/* 触屏设备：放大触控目标 */
@media (hover: none) and (pointer: coarse) {
  :root { --tap: 44px; }
  .seg button { min-height: 38px; }
  .lang-list a { min-height: 44px; }
}

/* 横屏且高度很小（手机横屏）：恢复左右两栏，保证主视图高度 */
@media (orientation: landscape) and (max-height: 480px) {
  .grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
  .grid > .card:last-child { grid-column: 1 / -1; }
  .hero { margin-bottom: 10px; }
  .hero-sub { display: none; }
  .files { max-height: 150px; }
  .preview-box { min-height: 140px; max-height: 200px; }
  .preview-box img { max-height: 160px; }
}

/* 打印：只留内容 */
@media print {
  .topbar, .dz-actions, .actions, .tip { display: none; }
}
