/* TexTool 转换器 — 深色优先，跟随系统亮暗 */

:root {
  --bg: #0f1115;
  --bg-soft: #161a21;
  --surface: #1a1f28;
  --surface-hi: #212734;
  --border: #2a3140;
  --border-hi: #3a4354;
  --text: #e6e9ef;
  --text-dim: #a2abbd;
  --text-faint: #6f7a8d;
  --accent: #5b9dff;
  --accent-hi: #7db0ff;
  --accent-dim: #1e3a63;
  --ok: #4ec98a;
  --ok-dim: #17422f;
  --warn: #e0b155;
  --warn-dim: #443617;
  --err: #ef6f6f;
  --err-dim: #4a2222;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .22);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fa;
    --bg-soft: #eef1f6;
    --surface: #ffffff;
    --surface-hi: #f7f9fc;
    --border: #dde3ec;
    --border-hi: #c6d0de;
    --text: #1a1f28;
    --text-dim: #58637a;
    --text-faint: #8b95a8;
    --accent: #2f6fd0;
    --accent-hi: #1f5cb8;
    --accent-dim: #e2ecfb;
    --ok: #1f9d5f;
    --ok-dim: #dff4e8;
    --warn: #96700f;
    --warn-dim: #fbf1d8;
    --err: #cf3b3b;
    --err-dim: #fbe3e3;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .07);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

code {
  font-family: var(--mono);
  font-size: .88em;
  padding: .12em .38em;
  border-radius: 4px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
}

/* ------------------------------------------------------------- 顶部 */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  padding-bottom: 14px;
  flex-wrap: wrap;
}

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

.brand-mark {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.brand-sub {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.brand-sub code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-dim);
}

.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.badge-ok {
  background: var(--ok-dim);
  border-color: transparent;
  color: var(--ok);
}

/* ------------------------------------------------------------- 卡片 */

main.wrap {
  flex: 1;
  padding-top: 24px;
  padding-bottom: 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card.is-hidden,
.is-hidden { display: none !important; }

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-head h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 620;
  letter-spacing: -.01em;
}

.card-head-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.chip {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.chip-ok {
  background: var(--ok-dim);
  border-color: transparent;
  color: var(--ok);
}

/* --------------------------------------------------------- 模式切换 */

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-hi);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color .15s, background .15s;
}

.mode-btn:hover { border-color: var(--border-hi); }

.mode-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.mode-icon { font-size: 20px; line-height: 1; flex-shrink: 0; }

.mode-text { display: flex; flex-direction: column; min-width: 0; }
.mode-text strong { font-size: 14px; font-weight: 600; }
.mode-text small { font-size: 11.5px; color: var(--text-dim); line-height: 1.35; }

/* ----------------------------------------------------------- 拖放区 */

.dropzone {
  border: 1.5px dashed var(--border-hi);
  border-radius: var(--radius-sm);
  background: var(--surface-hi);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  outline: none;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
  border-style: solid;
}

.dropzone-icon {
  font-size: 26px;
  color: var(--accent);
  margin-bottom: 8px;
  line-height: 1;
}

.dropzone-title {
  margin: 0 0 5px;
  font-size: 14.5px;
  font-weight: 550;
}

.dropzone-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

/* ----------------------------------------------------------- 选项 */

.options {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.options summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  user-select: none;
  list-style: none;
}

.options summary::-webkit-details-marker { display: none; }

.options summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform .15s;
}

.options[open] summary::before { content: "▾ "; }

.opt {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 9px 0 0;
  cursor: pointer;
}

.opt input {
  margin: 3px 0 0;
  accent-color: var(--accent);
  flex-shrink: 0;
  width: 15px;
  height: 15px;
}

.opt span { display: flex; flex-direction: column; }
.opt strong { font-size: 13.5px; font-weight: 550; }
.opt small { font-size: 12px; color: var(--text-dim); line-height: 1.4; }
.opt small code { font-size: 11.5px; }

.opt-group {
  margin-top: 12px;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-hi);
}

.opt-group-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.opt-group .opt:first-of-type { padding-top: 6px; }

.opt-tag {
  display: inline-block;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--ok-dim);
  color: var(--ok);
  margin-left: 5px;
  vertical-align: 1px;
}

.opt-tag-warn { background: var(--warn-dim); color: var(--warn); }

.engine-status {
  margin: 10px 0 0;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  line-height: 1.4;
}

.engine-status.is-err { background: var(--err-dim); color: var(--err); }
.engine-status.is-ok { background: var(--ok-dim); color: var(--ok); }

/* ----------------------------------------------------------- 表格 */

.table-scroll {
  max-height: 380px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overscroll-behavior: contain;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.file-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-hi);
  border-bottom: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
  font-weight: 550;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.file-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.file-table tbody tr:last-child td { border-bottom: none; }
.file-table tbody tr:hover { background: var(--surface-hi); }

.col-size { width: 84px; text-align: right; white-space: nowrap; }
.col-kind { width: 96px; }
.col-status { width: 190px; }
.col-act { width: 40px; }

.cell-name {
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
  line-height: 1.45;
}

.cell-path {
  color: var(--text-faint);
}

.cell-size {
  text-align: right;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.tag-anim { background: var(--accent-dim); color: var(--accent); border-color: transparent; }
.tag-nested { background: var(--warn-dim); color: var(--warn); border-color: transparent; }
.tag-tex { background: var(--ok-dim); color: var(--ok); border-color: transparent; }

.status {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1.35;
}

.status-ok { color: var(--ok); }
.status-skip { color: var(--text-faint); }
.status-err { color: var(--err); }
.status-run { color: var(--accent); }

.spinner {
  width: 11px;
  height: 11px;
  border: 2px solid var(--accent-dim);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  border: none;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 5px;
  border-radius: 5px;
  line-height: 1;
}

.icon-btn:hover { color: var(--err); background: var(--err-dim); }

.dl-btn {
  border: 1px solid var(--border);
  background: var(--surface-hi);
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 5px;
  white-space: nowrap;
}

.dl-btn:hover { border-color: var(--accent); background: var(--accent-dim); }

/* ----------------------------------------------------------- 按钮 */

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.actions-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.btn {
  font: inherit;
  font-weight: 550;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-hi);
  color: var(--text);
  padding: 8px 15px;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { border-color: var(--border-hi); }

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-lg { padding: 11px 26px; font-size: 14.5px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hi);
  border-color: var(--accent-hi);
}

.btn-ghost {
  background: none;
  border-color: transparent;
  color: var(--text-dim);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hi);
  color: var(--text);
}

/* --------------------------------------------------------- 进度条 */

.progress { margin-top: 14px; }

.progress-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-hi);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width .2s ease;
}

.progress-text {
  margin: 7px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------- 统计 */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px;
}

.stat {
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.stat-value {
  font-size: 21px;
  font-weight: 650;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

.stat-ok .stat-value { color: var(--ok); }
.stat-warn .stat-value { color: var(--warn); }
.stat-err .stat-value { color: var(--err); }

/* ----------------------------------------------------------- 说明 */

.card-info { background: var(--bg-soft); box-shadow: none; }

.card-info summary {
  cursor: pointer;
  font-size: 14px;
  user-select: none;
  list-style: none;
}

.card-info summary::-webkit-details-marker { display: none; }
.card-info summary::before { content: "▸ "; }
.card-info details[open] summary::before { content: "▾ "; }

.info-body { padding-top: 10px; }

.info-body ul {
  margin: 0;
  padding-left: 20px;
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.75;
}

.info-body li strong { color: var(--text); }

.info-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--ok-dim);
  color: var(--ok);
  font-size: 12.5px;
  line-height: 1.55;
}

/* ----------------------------------------------------------- 页脚 */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 16px 0;
  background: var(--bg-soft);
}

.site-footer p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-faint);
  text-align: center;
}

/* ----------------------------------------------------------- toast */

.toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  max-width: 340px;
  animation: toast-in .2s ease;
}

.toast-err { border-left-color: var(--err); }
.toast-ok { border-left-color: var(--ok); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* --------------------------------------------------------- 响应式 */

@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .card { padding: 16px 14px; }
  .mode-switch { grid-template-columns: 1fr; }
  .dropzone { padding: 26px 14px; }
  .col-kind, .col-size { display: none; }
  .col-status { width: 132px; }
  .header-inner { padding-top: 11px; padding-bottom: 11px; }
  .badge-row .badge:not(.badge-ok) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
