:root {
  color-scheme: light;
  --page: #f1f1f3;
  --paper: #fbfbfc;
  --white: #ffffff;
  --ink: #1c1c1e;
  --subtle: #707077;
  --faint: #96969d;
  --line: #d9d9de;
  --line-dark: #c9c9cf;
  --red: #aa2d35;
  --red-soft: #f8e9ea;
  --green: #27724d;
  --green-soft: #e9f4ed;
  --orange: #8b5b17;
  --orange-soft: #f7efe2;
  --mono: "SFMono-Regular", "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--page); scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  padding: calc(72px + env(safe-area-inset-top)) 0 calc(88px + env(safe-area-inset-bottom));
}
button, input, textarea { font: inherit; }
button { color: inherit; }

.topbar {
  position: fixed;
  z-index: 30;
  inset: 0 0 auto;
  height: calc(64px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(241, 241, 243, .96);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-icon { width: 34px; height: 34px; position: relative; background: var(--ink); border-radius: 9px; flex: none; }
.brand-icon::before { content: ""; position: absolute; inset: 7px 8px; background: var(--white); border-radius: 1px; }
.brand-icon::after { content: ""; position: absolute; inset: 10px 12px; background: var(--red); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: .95rem; letter-spacing: .01em; }
.brand small { color: var(--subtle); font-size: .67rem; margin-top: 1px; }
.connection { display: inline-flex; align-items: center; gap: 6px; color: var(--subtle); font-size: .72rem; }
.connection i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.connection.offline i { background: var(--orange); }

.shell { width: min(100%, 680px); margin: 0 auto; padding: 20px 16px 24px; }
.view { animation: appear .18s ease-out; }
.view[hidden] { display: none; }
@keyframes appear { from { opacity: .35; transform: translateY(4px); } }

.hero { padding: 20px 3px 26px; }
.eyebrow { margin: 0 0 10px; color: var(--red); font: 700 .68rem/1.2 var(--mono); letter-spacing: .13em; }
.hero h1, .page-title h1 { margin: 0; font-size: clamp(1.8rem, 9vw, 3rem); letter-spacing: -.045em; line-height: 1.08; }
.hero > p:last-child, .page-title > p:last-child { max-width: 36rem; margin: 14px 0 0; color: var(--subtle); line-height: 1.68; font-size: .92rem; }
.page-title { padding: 16px 3px 22px; }
.page-title h1 { font-size: 1.85rem; }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line-dark); background: var(--line-dark); gap: 1px; }
.quick { min-height: 138px; border: 0; padding: 17px; text-align: left; background: var(--paper); display: flex; flex-direction: column; align-items: flex-start; cursor: pointer; }
.quick.primary { background: var(--ink); color: white; }
.quick-index { color: var(--red); font: 700 .68rem var(--mono); }
.quick.primary .quick-index { color: #e47a80; }
.quick strong { margin-top: auto; font-size: 1.03rem; }
.quick small { margin-top: 5px; color: var(--subtle); line-height: 1.35; }
.quick.primary small { color: #bcbcc2; }

.panel { margin-top: 16px; padding: 18px; background: var(--paper); border: 1px solid var(--line); }
.panel.compact { padding: 17px 18px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.panel-head h2, .prose h2 { margin: 0; font-size: 1rem; }
.panel-head p { margin: 5px 0 0; color: var(--subtle); font-size: .78rem; }
.panel-head .eyebrow { margin-bottom: 5px; }
.text-action { border: 0; padding: 2px 0 8px 10px; color: var(--red); background: transparent; font-size: .82rem; font-weight: 700; cursor: pointer; }
.summary-list { margin: 0; }
.summary-list div { display: flex; justify-content: space-between; gap: 18px; padding: 11px 0; border-top: 1px solid var(--line); }
.summary-list dt { color: var(--subtle); }
.summary-list dd { margin: 0; font: 600 .82rem var(--mono); }

.install-callout { margin-top: 16px; padding: 15px 17px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; background: transparent; }
.install-callout strong { display: block; font-size: .88rem; }
.install-callout p { margin: 4px 0 0; color: var(--subtle); font-size: .74rem; }
.install-callout button { min-height: 36px; padding: 0 15px; border: 1px solid var(--ink); background: var(--ink); color: white; border-radius: 8px; font-size: .78rem; font-weight: 700; }

.file-picker { min-height: 104px; display: flex; align-items: center; gap: 14px; border: 1px dashed var(--line-dark); padding: 16px; cursor: pointer; background: var(--white); }
.file-picker.ready { border-style: solid; border-color: var(--red); }
.file-picker strong, .file-picker small { display: block; }
.file-picker strong { font-size: .92rem; }
.file-picker small { color: var(--subtle); margin-top: 5px; line-height: 1.4; }
.file-plus { width: 38px; height: 38px; display: grid; place-items: center; flex: none; border: 1px solid var(--line-dark); border-radius: 50%; font-size: 1.35rem; font-weight: 300; }
.selected-file { margin-top: 10px; padding: 10px 12px; background: var(--page); font: .73rem/1.5 var(--mono); word-break: break-all; }
.inline-actions { margin-top: 13px; display: flex; align-items: center; gap: 12px; }
.inline-actions span { color: var(--subtle); font-size: .75rem; }
.secondary { min-height: 38px; border: 1px solid var(--line-dark); border-radius: 8px; padding: 0 13px; background: transparent; font-size: .78rem; font-weight: 700; }
.main-action { width: 100%; min-height: 50px; margin-top: 16px; border: 1px solid var(--ink); border-radius: 9px; background: var(--ink); color: white; font-weight: 750; cursor: pointer; }
.main-action:disabled { opacity: .36; cursor: default; }
.progress { height: 3px; margin-top: 12px; overflow: hidden; background: var(--line); }
.progress i { display: block; width: 35%; height: 100%; background: var(--red); animation: loading 1s infinite ease-in-out; }
@keyframes loading { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }

.notice { margin-top: 13px; padding: 11px 12px; border-left: 3px solid var(--ink); background: var(--page); font-size: .8rem; line-height: 1.55; white-space: pre-wrap; }
.notice.good { color: var(--green); border-color: var(--green); background: var(--green-soft); }
.notice.bad { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.notice.warn { color: var(--orange); border-color: var(--orange); background: var(--orange-soft); }
.result-stack { display: grid; gap: 10px; margin-top: 12px; }
.result-card { border: 1px solid var(--line); background: var(--paper); padding: 16px 17px; }
.result-card .tagline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.result-card .tag { color: var(--red); font: 700 .68rem var(--mono); letter-spacing: .08em; }
.result-card .count { color: var(--subtle); font-size: .72rem; }
.result-card h3 { margin: 12px 0 5px; font-size: 1.3rem; word-break: break-word; }
.result-card h3.mono { font-family: var(--mono); font-size: 1.1rem; }
.result-card p { margin: 6px 0 0; color: var(--subtle); font-size: .8rem; line-height: 1.55; }
.path-list { margin: 13px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.path-list li { padding: 9px 0; border-bottom: 1px solid var(--line); color: #55555d; font: .7rem/1.45 var(--mono); word-break: break-all; }
.path-list b { color: var(--ink); font-family: inherit; }
.copy-action { margin-top: 13px; min-height: 38px; border: 1px solid var(--line-dark); border-radius: 8px; background: transparent; padding: 0 13px; font-size: .76rem; font-weight: 700; }

.retain-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.retain-row input { width: 19px; height: 19px; accent-color: var(--red); }
.retain-row strong, .retain-row small { display: block; }
.retain-row strong { font-size: .82rem; }
.retain-row small { margin-top: 3px; color: var(--subtle); font-size: .7rem; }
.field-grid { display: grid; gap: 13px; margin-top: 15px; }
.field { display: block; margin-top: 14px; }
.field-grid .field { margin: 0; }
.field > span { display: block; margin-bottom: 7px; color: #4d4d53; font-size: .79rem; font-weight: 700; }
.field input, .field textarea { width: 100%; border: 1px solid var(--line-dark); border-radius: 8px; outline: 0; background: var(--white); padding: 12px 13px; color: var(--ink); }
.field input { min-height: 46px; }
.field textarea { min-height: 112px; resize: vertical; font: .74rem/1.5 var(--mono); }
.field input:focus, .field textarea:focus { border-color: var(--red); box-shadow: 0 0 0 2px rgba(170,45,53,.09); }

.list-panel { padding: 0; }
.list-row { width: 100%; min-height: 70px; padding: 13px 16px; border: 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 15px; background: transparent; text-align: left; text-decoration: none; color: inherit; }
.list-row:last-child { border-bottom: 0; }
.list-row strong, .list-row small { display: block; }
.list-row strong { font-size: .85rem; }
.list-row small { margin-top: 4px; color: var(--subtle); font-size: .7rem; line-height: 1.4; }
.list-row b { font-size: 1.4rem; font-weight: 300; color: var(--faint); }
.list-row.danger strong { color: var(--red); }
.prose p { color: var(--subtle); font-size: .8rem; line-height: 1.7; }

.tabbar { position: fixed; z-index: 40; inset: auto 0 0; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5,1fr); background: rgba(250,250,251,.97); border-top: 1px solid var(--line); }
.tabbar button, .tabbar a { border: 0; background: transparent; color: var(--subtle); text-decoration: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.tabbar button span, .tabbar a span { min-height: 18px; font: 700 1rem/1 var(--mono); }
.tabbar button small, .tabbar a small { font-size: .63rem; }
.tabbar button.active, .tabbar a.active { color: var(--red); }

dialog { width: min(calc(100% - 30px), 430px); border: 1px solid var(--line-dark); border-radius: 12px; padding: 18px; background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgba(15,15,17,.35); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head button { border: 0; background: transparent; font-size: 1.4rem; }
dialog ol { margin: 18px 0; padding-left: 22px; color: var(--subtle); font-size: .84rem; line-height: 1.7; }

@media (min-width: 640px) {
  .shell { padding-top: 30px; }
  .field-grid { grid-template-columns: 1fr 1fr; }
  .hero { padding-top: 32px; }
}

@media (display-mode: standalone) {
  .install-callout, #installRow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
