:root {
  --brand: #615ced;
  --brand-2: #3d6bff;
  --brand-soft: rgba(97, 92, 237, 0.12);
  --bg: #f4f4f6;
  --sidebar: #fafafa;
  --surface: #ffffff;
  --text: #1c1c1f;
  --muted: #8a8a93;
  --line: #ebebef;
  --danger: #e11d48;
  --good: #0f9f6e;
  --control-h: 36px;
  --shadow: 0 10px 40px rgba(28, 28, 31, 0.08);
  --page-w: 1200px;
  --font: ui-monospace, "SF Mono", "Sarasa Mono SC", "Microsoft YaHei Mono", "Noto Sans Mono CJK SC", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --font-num: "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color-scheme: light;
}

html[data-theme="dark"] {
  --brand: #8b7cff;
  --brand-2: #6b8cff;
  --brand-soft: rgba(139, 124, 255, 0.16);
  --bg: #121214;
  --sidebar: #18181b;
  --surface: #1e1e22;
  --text: #ececef;
  --muted: #9a9aa3;
  --line: #2c2c32;
  --good: #3dcea0;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  letter-spacing: -0.015em;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--surface);
}
.site-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px 16px;
  min-height: 60px;
  padding: 10px max(20px, calc((100% - var(--page-w)) / 2));
  background: var(--sidebar);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  min-width: 0;
}
.brand img { border-radius: 9px; display: block; }
.brand-text { white-space: nowrap; }
.icon-btn {
  width: var(--control-h);
  height: var(--control-h);
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--brand-soft); color: var(--text); }
#btnTheme { margin-left: auto; }
.menu-btn { display: none; }
html.is-home .tool-nav,
html.is-home .menu-btn { display: none; }
.tool-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  min-height: var(--control-h);
  padding: 0 12px;
  border-radius: 10px;
  color: var(--text);
  font-size: 0.88rem;
  white-space: nowrap;
}
.nav-link svg { flex: none; }
.nav-link:hover,
.nav-link.active { background: var(--brand-soft); color: var(--text); }

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  background: var(--surface);
}
#view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.home {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 28px 0 36px;
}
.home-inner {
  width: min(var(--page-w), calc(100% - 40px));
  margin: 0 auto;
}
.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.home-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  min-height: 168px;
  padding: 22px 20px 20px;
  text-decoration: none;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.home-card:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.home-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--brand);
}
.home-card strong {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.home-card span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.tool-scroll { flex: 1; overflow: auto; padding: 8px 0 28px; }
.tool { width: min(var(--page-w), calc(100% - 40px)); margin: 8px auto 0; }
.tool-head h1 { margin: 0 0 6px; font-size: 1.45rem; font-weight: 700; }
.tool-head p { margin: 0 0 18px; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
.tool-grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.panel {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}
.out-panel { min-height: 280px; }
.drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 132px;
  margin-bottom: 14px;
  padding: 18px 14px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.drop strong { color: var(--text); font-size: 0.95rem; }
.drop span { font-size: 0.78rem; line-height: 1.45; }
.drop:hover,
.drop:focus-within,
.drop.is-drag {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.picked { margin: -6px 0 12px; color: var(--muted); font-size: 0.78rem; }
.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -6px 0 12px;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 8px 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.78rem;
}
.file-chip .file-name { max-width: 148px; }
.chip-x {
  border: 0;
  padding: 0 2px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}
.chip-x:hover { color: var(--danger); }
.result-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin: 0 0 10px;
}
.result-summary { margin: 0; color: var(--muted); font-size: 0.82rem; }
.delta-note { display: block; color: var(--danger); font-size: 0.75rem; font-weight: 500; }
.size-note { display: block; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.field span,
.field-label {
  font-size: 0.78rem;
  color: var(--muted);
}
.field-label { display: block; margin: 2px 0 6px; }
.field input,
.field select,
.field textarea,
.panel > textarea {
  width: 100%;
  height: var(--control-h);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 0.9rem;
  outline: none;
}
.field textarea,
.panel > textarea {
  height: auto;
  min-height: 180px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}
.wide-tool { width: min(var(--page-w), calc(100% - 40px)); }
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.compare.is-better { border-color: var(--brand); }
.qr-stage {
  display: flex;
  justify-content: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.qr-stage canvas { width: min(100%, 280px); height: auto; }
.studio-preview {
  display: block;
  max-width: 100%;
  max-height: 420px;
  margin: 0 auto;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.text-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.field input[type="range"] {
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--brand);
}
.color-field {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: var(--control-h);
  padding: 3px 12px 3px 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.color-field:focus-within { border-color: var(--brand); }
.field .color-field input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--text) 22%, transparent);
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  flex: none;
  overflow: hidden;
}
.field .color-field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
.field .color-field input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 6px;
}
.field .color-field input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 6px;
}
.color-hex {
  font-family: var(--font-num);
  font-size: 0.9rem;
  color: var(--text);
  letter-spacing: 0.02em;
}
.field input:focus,
.field select:focus { border-color: var(--brand); }
.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  margin: 0 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.seg button {
  flex: 1;
  min-height: 30px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0 4px;
}
.seg button[aria-pressed="true"] {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 0.84rem;
}
.check input { accent-color: var(--brand); }
.form-error { margin: 8px 0 0; color: var(--danger); font-size: 0.84rem; line-height: 1.45; }
.fine-print { margin: 4px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }
.working { margin: 0; color: var(--muted); }
.empty {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  color: var(--muted);
}
.empty strong { color: var(--text); font-size: 0.95rem; }
.empty span { font-size: 0.8rem; max-width: 280px; line-height: 1.5; }

.delta { font-size: 0.82rem; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--danger); }
.actions { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 12px; }
.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-h);
  padding: 0 16px;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 600;
}
.btn-primary {
  border: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(97, 92, 237, 0.28);
}
.btn-primary:hover { filter: brightness(1.05); color: #fff; }
.btn-ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.link-btn {
  display: inline;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--brand);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
}
.link-btn:hover { color: var(--brand); text-decoration: underline; }
.result-sheet { margin-top: 0; max-height: 520px; }
table.result-table th,
table.result-table td {
  text-align: left;
  vertical-align: middle;
}
table.result-table td.num { text-align: right; }
table.result-table td.delta { margin: 0; }
.result-table .preview-cell { width: 52px; }
.result-table .thumb {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--line);
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #ececf1 25%, transparent 25%),
    linear-gradient(-45deg, #ececf1 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ececf1 75%),
    linear-gradient(-45deg, transparent 75%, #ececf1 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
  display: block;
}
html[data-theme="dark"] .result-table .thumb {
  background-color: #16161a;
  background-image:
    linear-gradient(45deg, #2a2a30 25%, transparent 25%),
    linear-gradient(-45deg, #2a2a30 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2a2a30 75%),
    linear-gradient(-45deg, transparent 75%, #2a2a30 75%);
}
.result-table .file-name { max-width: 168px; }
.file-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
}
.result-table .form-error { margin: 0; }

.hero { margin-bottom: 14px; }
.kicker { margin: 0 0 4px; color: var(--muted); font-size: 0.78rem; }
.hero-num {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}
.hero-num small {
  margin-left: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.stat {
  background: var(--surface);
  border-radius: 12px;
  padding: 10px 12px;
}
.stat em { display: block; margin-bottom: 4px; color: var(--muted); font-style: normal; font-size: 0.75rem; }
.stat b { display: block; font-size: 0.98rem; font-weight: 700; }
.parts { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.compare {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.compare p { margin: 0; color: var(--text); font-size: 0.86rem; line-height: 1.55; }
.compare span { color: var(--muted); }
.view-seg { margin: 12px 0 0; }
.sheet tr.is-prepay td { color: var(--brand); font-weight: 600; }
.part-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  font-size: 0.86rem;
}
.sheet-wrap {
  overflow: auto;
  max-height: 420px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
table.sheet { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.sheet th,
.sheet td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.sheet th:first-child,
.sheet td:first-child { text-align: left; }
.sheet th {
  position: sticky;
  top: 0;
  background: var(--sidebar);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
}
.out-panel .actions { margin-top: 12px; }
.noscript {
  margin: 24px 16px;
  color: var(--muted);
  text-align: center;
}

.site-foot {
  flex-shrink: 0;
  margin-top: 0;
  padding: 12px max(16px, calc((100% - var(--page-w)) / 2)) calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--sidebar);
  border-top: 1px solid var(--line);
}
.legal-nav,
.beian {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 14px;
}
.legal-nav { margin-bottom: 4px; }
.legal-nav a,
.beian a {
  color: var(--muted);
  font-size: 0.72rem;
  text-decoration: none;
}
.beian li { display: flex; align-items: center; }
.beian a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 17px;
  line-height: 17px;
}
.beian img {
  display: block;
  width: 16px;
  height: 17px;
  max-width: none;
  flex: none;
  object-fit: contain;
}
.legal-nav a:hover,
.beian a:hover { color: var(--text); }

.legal-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}
.legal-inner { width: min(720px, 100%); margin: 0 auto 28px; padding: 28px 16px 0; }
.legal-back { display: inline-block; margin-bottom: 18px; color: var(--brand); font-size: 0.95rem; }
.legal-inner h1 { margin: 0 0 8px; font-size: 1.55rem; font-weight: 600; }
.legal-meta { margin: 0 0 22px; color: var(--muted); font-size: 0.9rem; line-height: 1.6; }
.legal-body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 18px;
}
.legal-body h2 { margin: 22px 0 10px; font-size: 1.05rem; }
.legal-body h2:first-child { margin-top: 0; }
.legal-body p,
.legal-body li { line-height: 1.65; font-size: 0.95rem; }
.legal-body p { margin: 0 0 10px; }
.legal-body ul,
.legal-body ol { margin: 0 0 10px; padding-left: 1.2em; }
.legal-body li { margin-bottom: 6px; }
.legal-wrap .site-foot { margin-top: auto; }

.nf {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  background: var(--bg);
}
.nf-card {
  width: min(420px, calc(100% - 40px));
  margin: auto;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 36px 24px 28px;
  box-shadow: var(--shadow);
}
.nf-card img {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  margin-bottom: 12px;
}
.nf-code {
  margin: 0;
  font-size: 3.2rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--brand);
}
.nf-card h1 { margin: 4px 0 8px; font-size: 1.35rem; }
.nf-card p { margin: 0 0 20px; color: var(--muted); }
.nf .site-foot { width: 100%; margin-top: auto; }

@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .site-head { flex-wrap: wrap; padding: 10px 14px; }
  .tool-nav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    order: 3;
    padding-top: 4px;
  }
  .app.nav-open .tool-nav { display: flex; }
  html.is-home .tool-nav,
  html.is-home .menu-btn { display: none; }
  .nav-link { padding: 8px 12px; }
  .home-inner { width: min(var(--page-w), calc(100% - 28px)); }
  .home-grid,
  .tool-grid,
  .stat-grid,
  .compare-grid { grid-template-columns: 1fr; }
  .wide-tool { width: min(var(--page-w), calc(100% - 28px)); }
  .tool { width: min(var(--page-w), calc(100% - 28px)); }
}
