:root {
  --ink: #17221e;
  --ink-soft: #34423c;
  --muted: #718079;
  --canvas: #f3f5f1;
  --panel: #ffffff;
  --line: #dde4df;
  --line-soft: #edf1ee;
  --accent: #c9512d;
  --accent-dark: #9f3d20;
  --accent-soft: #fff0e9;
  --green: #247050;
  --green-soft: #e9f6ef;
  --blue: #3f6f9a;
  --shadow: 0 18px 55px rgba(29, 45, 38, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 22px 22px; display: flex; flex-direction: column; color: #fff; background: #18251f; }
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 13px; color: #fff; background: var(--accent); box-shadow: 0 8px 22px rgba(201,81,45,.28); }
.brand-mark svg { width: 25px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .02em; }
.brand small { margin-top: 2px; color: rgba(255,255,255,.5); font-size: 11px; }
.side-nav { display: grid; gap: 6px; margin-top: 44px; }
.nav-item { display: flex; gap: 12px; align-items: center; padding: 12px 13px; border-radius: 11px; color: rgba(255,255,255,.6); text-decoration: none; font-size: 13px; transition: .18s ease; }
.nav-item svg { width: 19px; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.is-active { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-note { margin-top: auto; padding: 14px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid rgba(255,255,255,.09); border-radius: 13px; background: rgba(255,255,255,.045); }
.status-dot { width: 8px; height: 8px; margin-top: 5px; flex: 0 0 auto; border-radius: 50%; background: #d2a14d; box-shadow: 0 0 0 4px rgba(210,161,77,.12); }
.status-dot.is-online { background: #5fc590; box-shadow: 0 0 0 4px rgba(95,197,144,.12); }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: 11px; }
.sidebar-note small { margin-top: 4px; color: rgba(255,255,255,.45); font-size: 9px; line-height: 1.5; }
.version { margin: 15px 3px 0; color: rgba(255,255,255,.28); font-size: 9px; letter-spacing: .08em; }

.main-shell { min-width: 0; }
.topbar { min-height: 86px; padding: 18px 34px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); backdrop-filter: blur(14px); }
.topbar-title p { margin: 0 0 5px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .15em; }
.topbar-title h1 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.secure-badge { display: inline-flex; gap: 8px; align-items: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft); background: #fff; font-size: 11px; }
.secure-badge span { width: 7px; height: 7px; border-radius: 50%; background: #36ad72; box-shadow: 0 0 0 4px rgba(54,173,114,.11); }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: #fff; cursor: pointer; }
.icon-button:hover { color: var(--accent); border-color: #edc3b5; }
.icon-button svg { width: 19px; }
.mobile-brand { display: none; }

main { width: min(1220px, calc(100% - 64px)); margin: 0 auto; padding: 36px 0 24px; }
.intro-row { display: flex; gap: 30px; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.intro-row h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 34px; font-weight: 500; letter-spacing: -.025em; }
.intro-row p { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.stepper { display: flex; align-items: center; }
.step-item { display: flex; gap: 8px; align-items: center; color: #9ba69f; }
.step-item span { width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #fff; font-size: 10px; font-weight: 800; }
.step-item small { font-size: 10px; white-space: nowrap; }
.step-item.is-current { color: var(--accent); }
.step-item.is-current span { color: #fff; border-color: var(--accent); background: var(--accent); }
.step-item.is-done { color: var(--green); }
.step-item.is-done span { color: #fff; border-color: var(--green); background: var(--green); }
.stepper i { width: 38px; height: 1px; margin: 0 8px; background: var(--line); }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(310px, .72fr); gap: 20px; align-items: start; }
.card { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
.upload-card, .rules-card { padding: 25px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 19px; }
.section-kicker { display: block; margin-bottom: 5px; color: var(--accent); font-size: 8px; font-weight: 850; letter-spacing: .16em; }
.card-header h3, .progress-head h3, .result-copy h3, .dialog-head h3 { margin: 0; font-size: 16px; }
.ghost-button { padding: 8px 10px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; }
.ghost-button:hover { color: var(--accent-dark); background: var(--accent-soft); }

.drop-zone { width: 100%; min-height: 128px; padding: 22px; display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; text-align: left; border: 1.5px dashed #cbd6cf; border-radius: 14px; color: var(--ink); background: #f9fbf9; cursor: pointer; transition: .18s ease; }
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--accent); background: #fff8f4; transform: translateY(-1px); }
.drop-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 15px; color: var(--accent); background: var(--accent-soft); }
.drop-icon svg { width: 28px; }
.drop-copy strong, .drop-copy small { display: block; }
.drop-copy strong { font-size: 14px; }
.drop-copy small { margin-top: 6px; color: var(--muted); font-size: 10px; }
.browse-label { padding: 9px 12px; border: 1px solid #e4b9aa; border-radius: 9px; color: var(--accent-dark); background: #fff; font-size: 10px; font-weight: 750; }
.empty-hint { padding: 30px 0 22px; text-align: center; color: #9ba69f; }
.empty-hint span { display: inline-grid; width: 34px; height: 28px; place-items: center; border-radius: 6px; color: #fff; background: #aeb9b2; font-size: 8px; font-weight: 800; }
.empty-hint p { margin: 8px 0 3px; color: var(--muted); font-size: 11px; }
.empty-hint small { font-size: 9px; }

.file-list { display: grid; gap: 8px; margin-top: 14px; }
.file-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 11px; align-items: center; padding: 11px 12px; border: 1px solid var(--line-soft); border-radius: 11px; background: #fbfcfb; }
.file-type { display: grid; width: 34px; height: 38px; place-items: center; border-radius: 7px; color: #fff; background: var(--accent); font-size: 8px; font-weight: 850; }
.file-meta { min-width: 0; }
.file-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.file-meta small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.file-status { padding: 5px 8px; border-radius: 999px; color: var(--muted); background: #eef2ef; font-size: 8px; font-weight: 750; }
.file-status.is-processing { color: #8b641c; background: #fff4d7; }
.file-status.is-done { color: var(--green); background: var(--green-soft); }
.file-status.is-error { color: #a93427; background: #fdebe7; }
.row-actions { display: flex; gap: 2px; }
.row-button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; }
.row-button:hover { color: var(--accent); background: var(--accent-soft); }
.row-button svg { width: 15px; }
.row-button.remove { font-size: 16px; }

.action-bar { margin-top: 17px; padding-top: 17px; display: flex; gap: 18px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line-soft); }
.selection-summary { display: flex; gap: 6px; align-items: baseline; color: var(--muted); font-size: 10px; }
.selection-summary strong { color: var(--ink); font-size: 20px; }
.primary-button, .download-button { min-height: 42px; display: inline-flex; gap: 10px; align-items: center; justify-content: center; border: 0; border-radius: 11px; color: #fff; background: var(--accent); cursor: pointer; text-decoration: none; font-size: 11px; font-weight: 800; transition: .18s ease; }
.primary-button { min-width: 190px; padding: 0 17px; }
.primary-button svg, .download-button svg { width: 17px; }
.primary-button:hover:not(:disabled), .download-button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.primary-button:disabled { opacity: .38; cursor: not-allowed; }
.primary-button.is-loading svg { animation: pulseArrow 1s ease-in-out infinite alternate; }
@keyframes pulseArrow { to { transform: translateX(4px); } }
.status-text { min-height: 16px; margin: 9px 2px 0; color: var(--muted); font-size: 10px; }
.status-text.is-error { color: #aa3427; }

.rules-badge { padding: 6px 8px; border-radius: 8px; color: #fff; background: var(--ink); font-size: 8px; font-weight: 850; letter-spacing: .08em; }
.rule-list { display: grid; }
.rule-item { min-height: 64px; display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: center; border-bottom: 1px solid var(--line-soft); }
.rule-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; font-size: 9px; font-weight: 850; }
.rule-icon.keep { color: var(--green); background: var(--green-soft); }
.rule-icon.remove { color: var(--accent); background: var(--accent-soft); }
.rule-icon.change { color: var(--blue); background: #eaf2f9; }
.rule-item strong, .rule-item small { display: block; }
.rule-item strong { font-size: 10px; }
.rule-item small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.rule-state { color: #9aa59f; font-size: 8px; }
.privacy-box { margin-top: 18px; padding: 14px; display: flex; gap: 11px; align-items: flex-start; border-radius: 12px; color: #fff; background: var(--ink); }
.privacy-box svg { width: 20px; flex: 0 0 auto; color: #79d4a6; }
.privacy-box strong { display: block; font-size: 10px; }
.privacy-box p { margin: 5px 0 0; color: rgba(255,255,255,.52); font-size: 8.5px; line-height: 1.6; }

.progress-card { margin-top: 20px; padding: 24px 25px; }
.progress-head { display: flex; align-items: center; justify-content: space-between; }
.progress-head > strong { color: var(--accent); font-size: 18px; }
.progress-track { height: 7px; margin: 19px 0 22px; overflow: hidden; border-radius: 999px; background: #edf1ee; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #e99170); transition: width .35s ease; }
.progress-stages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.progress-stage { padding: 12px; display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; border: 1px solid var(--line-soft); border-radius: 11px; color: #9ca79f; }
.progress-stage > span { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: #f0f3f1; font-size: 8px; font-weight: 800; }
.progress-stage strong, .progress-stage small { display: block; }
.progress-stage strong { font-size: 9px; }
.progress-stage small { margin-top: 3px; font-size: 8px; }
.progress-stage.is-active { color: var(--ink); border-color: #efc7b9; background: #fffaf7; }
.progress-stage.is-active > span { color: #fff; background: var(--accent); }
.progress-stage.is-done { color: var(--green); }
.progress-stage.is-done > span { color: #fff; background: var(--green); }

.result-card { margin-top: 20px; padding: 24px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 17px; align-items: center; border: 1px solid #baddc9; border-radius: 18px; background: linear-gradient(135deg, #f0faf4, #fff); box-shadow: var(--shadow); }
.result-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-size: 20px; box-shadow: 0 8px 22px rgba(36,112,80,.2); }
.result-copy { min-width: 0; }
.result-copy .section-kicker { color: var(--green); }
.result-copy p { margin: 6px 0; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.result-filename { display: block; width: 100%; max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); font-size: 9px; }
.result-actions { min-width: 0; display: flex; gap: 8px; align-items: center; }
.download-button { padding: 0 15px; background: var(--green); }
.result-actions .ghost-button { border: 1px solid var(--line); background: #fff; }

footer { margin-top: 30px; padding: 18px 0 2px; display: flex; justify-content: space-between; color: #98a49d; font-size: 8.5px; }

.preview-dialog { width: min(960px, calc(100% - 30px)); height: min(760px, calc(100vh - 30px)); padding: 0; overflow: hidden; border: 0; border-radius: 18px; color: var(--ink); background: #fff; box-shadow: 0 30px 100px rgba(0,0,0,.25); }
.preview-dialog::backdrop { background: rgba(17,27,23,.65); backdrop-filter: blur(4px); }
.dialog-head { height: 72px; padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-head .icon-button { font-size: 22px; }
.preview-body { height: calc(100% - 72px); display: grid; place-items: center; overflow: auto; padding: 22px; background: #e7ebe8; }
.preview-body img { display: block; max-width: 100%; height: auto; border-radius: 6px; background: #fff; box-shadow: 0 12px 38px rgba(20,32,27,.16); }
.preview-loading { display: grid; gap: 12px; place-items: center; color: var(--muted); font-size: 11px; }
.preview-loading span { width: 30px; height: 30px; border: 3px solid #cbd5cf; border-top-color: var(--accent); border-radius: 50%; animation: previewSpin .8s linear infinite; }
@keyframes previewSpin { to { transform: rotate(360deg); } }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: 360px; padding: 12px 15px; border-radius: 11px; color: #fff; background: var(--ink); box-shadow: var(--shadow); font-size: 10px; opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: #9e3428; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-brand { display: flex; gap: 9px; align-items: center; }
  .mobile-brand .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .mobile-brand .brand-mark svg { width: 21px; }
  .topbar-title { display: none; }
  .workspace-grid { grid-template-columns: 1fr; }
  .rules-card { order: 2; }
}

@media (max-width: 700px) {
  .topbar { min-height: 70px; padding: 14px 16px; }
  .secure-badge { display: none; }
  main { width: calc(100% - 24px); padding-top: 24px; }
  .intro-row { display: block; }
  .intro-row h2 { font-size: 28px; }
  .intro-row p { font-size: 11px; line-height: 1.6; }
  .stepper { margin-top: 20px; justify-content: space-between; }
  .stepper i { flex: 1; width: auto; }
  .step-item { display: block; text-align: center; }
  .step-item span { margin: 0 auto 5px; }
  .upload-card, .rules-card, .progress-card { padding: 18px; }
  .drop-zone { min-height: 180px; grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .browse-label { display: none; }
  .file-item { grid-template-columns: auto minmax(0, 1fr) auto; }
  .file-status { display: none; }
  .action-bar { display: block; }
  .selection-summary { margin-bottom: 12px; }
  .primary-button { width: 100%; }
  .progress-stages { grid-template-columns: 1fr; }
  .result-card { grid-template-columns: auto 1fr; }
  .result-actions { grid-column: 1 / -1; width: 100%; display: grid; }
  .download-button { width: 100%; }
  footer { display: block; line-height: 1.9; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
