:root {
  color-scheme: light;
  --ink: #14221d;
  --muted: #68766f;
  --line: #dce4df;
  --soft: #f3f6f4;
  --paper: #ffffff;
  --accent: #1c7c54;
  --accent-dark: #125c3d;
  --accent-pale: #e3f4eb;
  --warning: #bf6b20;
  --danger: #b34545;
  --shadow: 0 18px 50px rgba(25, 48, 38, 0.08);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(rgba(20, 34, 29, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 34, 29, 0.025) 1px, transparent 1px),
    #f8faf9;
  background-size: 28px 28px;
}

button, input { font: inherit; }
button { color: inherit; }
input { color: var(--ink); }

.topbar {
  height: 68px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(209, 220, 214, 0.8);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--ink);
}

.brand-mark span {
  width: 14px;
  height: 10px;
  border: 2px solid #74d3a8;
  border-top: 0;
  border-radius: 2px 2px 8px 8px;
  position: relative;
}

.brand-mark span::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 7px;
  left: -1px;
  top: -6px;
  border: 2px solid #74d3a8;
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
}

.system-state {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa59f;
  box-shadow: 0 0 0 4px #eef1ef;
}

.state-dot.online { background: #2aa56d; box-shadow: 0 0 0 4px #dcf3e7; }
.state-dot.offline { background: #cc5555; box-shadow: 0 0 0 4px #f7e3e3; }

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 64px 0 70px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 48px;
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.16em;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 14px; font-size: clamp(36px, 5vw, 58px); letter-spacing: -0.05em; line-height: 1; }
.hero-copy { max-width: 660px; margin-bottom: 0; color: var(--muted); font-size: 16px; line-height: 1.75; }

.pipeline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  color: #53625b;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.pipeline i { width: 20px; height: 1px; background: #b7c4bd; position: relative; }
.pipeline i::after { content: ""; position: absolute; right: 0; top: -2px; width: 5px; height: 5px; border-top: 1px solid #89968f; border-right: 1px solid #89968f; transform: rotate(45deg); }

.workspace { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 22px; }
.panel { min-height: 430px; padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: var(--shadow); }

.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.panel-heading > div, .section-title { display: flex; align-items: center; gap: 12px; }
.step { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 0.12em; }
.panel-heading h2, .section-title h2 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.file-rule { color: #89948f; font-size: 11px; }

.drop-zone {
  width: 100%;
  min-height: 224px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1.5px dashed #b9c8c0;
  border-radius: 14px;
  background: #f8faf9;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.dragging { border-color: var(--accent); background: #f0f8f4; outline: none; }
.drop-zone.dragging { transform: translateY(-2px); }
.drop-zone strong { font-size: 15px; }
.drop-zone > span:last-child { color: var(--muted); font-size: 13px; }

.upload-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 4px; border-radius: 50%; background: var(--accent-pale); }
.upload-icon span { width: 16px; height: 18px; border: 2px solid var(--accent); border-radius: 3px; position: relative; }
.upload-icon span::before { content: ""; position: absolute; width: 7px; height: 7px; left: 2px; top: 5px; border-left: 2px solid var(--accent); border-top: 2px solid var(--accent); transform: rotate(45deg); }

.file-card { display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.file-card img { width: 56px; height: 52px; object-fit: cover; border-radius: 8px; }
.file-meta { min-width: 0; flex: 1; display: grid; gap: 5px; }
.file-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.file-meta span { color: var(--muted); font-size: 12px; }
.icon-button { width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 22px; }
.icon-button:hover { background: #e6ebe8; color: var(--ink); }

.settings-panel { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfb; }
.settings-panel summary { min-height: 46px; padding: 0 14px; display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; font-weight: 700; }
.settings-panel summary::marker { color: var(--accent); }
.settings-panel summary small { margin-left: auto; color: var(--muted); font-size: 10px; font-weight: 500; }
.settings-grid { padding: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; border-top: 1px solid var(--line); }
.setting-field { min-width: 0; display: grid; gap: 7px; color: var(--muted); font-size: 11px; }
.setting-field > span { color: var(--ink); font-weight: 650; }
.setting-field input[type="number"] { width: 100%; min-width: 0; height: 38px; padding: 0 9px; border: 1px solid #cfd9d3; border-radius: 8px; background: white; outline: none; }
.setting-field input[type="number"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(28, 124, 84, 0.1); }
.setting-field small { line-height: 1.4; }
.input-with-unit { position: relative; }
.input-with-unit input { padding-right: 32px !important; }
.input-with-unit span { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: #89948f; font-size: 10px; pointer-events: none; }
.setting-toggles { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 18px; padding-top: 2px; }
.setting-toggles label { display: flex; align-items: center; gap: 7px; color: #53625b; cursor: pointer; font-size: 11px; }
.setting-toggles input { width: 15px; height: 15px; accent-color: var(--accent); }
.reset-settings { margin: 0 14px 14px; padding: 0; border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: 11px; }
.reset-settings:hover { text-decoration: underline; }

.primary-button {
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
  border: 0;
  border-radius: 11px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}
.primary-button:not(:disabled):hover { background: #253a32; }
.primary-button:disabled { cursor: not-allowed; opacity: 0.42; }
.primary-button.loading .button-label { display: none; }
.spinner { display: none; width: 19px; height: 19px; margin: auto; border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: white; border-radius: 50%; animation: spin 0.8s linear infinite; }
.primary-button.loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-message { min-height: 18px; margin: 10px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.status-message.error { color: var(--danger); }

.result-badge { padding: 6px 10px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.result-badge.idle { background: #edf0ee; color: #7a8580; }
.result-badge.safe { background: var(--accent-pale); color: var(--accent-dark); }
.result-badge.unsafe { background: #fbe9df; color: #a34e18; }
.result-badge.unknown { background: #fff3d9; color: #8c661a; }

.metric-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.metric { min-height: 80px; padding: 15px 16px; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.metric:nth-child(odd) { border-right: 1px solid var(--line); }
.metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
.metric span { color: var(--muted); font-size: 11px; }
.metric strong { font-size: 17px; letter-spacing: -0.02em; }

.empty-result { min-height: 174px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #929d98; font-size: 13px; }
.empty-result p { margin: 0; }
.scan-frame { width: 46px; height: 46px; border: 1px solid #c8d1cc; position: relative; }
.scan-frame::before, .scan-frame::after { content: ""; position: absolute; background: #f8faf9; }
.scan-frame::before { left: 9px; right: 9px; top: -2px; bottom: -2px; }
.scan-frame::after { top: 9px; bottom: 9px; left: -2px; right: -2px; }

.cue-list { margin-top: 22px; }
.cue-list h3 { margin-bottom: 10px; font-size: 12px; color: var(--muted); font-weight: 600; }
.people-list { max-height: 180px; overflow: auto; border-top: 1px solid #edf0ee; }
.person-result { display: grid; grid-template-columns: 28px 1fr; align-items: baseline; padding: 9px 0; border-bottom: 1px solid #edf0ee; }
.person-result span { color: var(--accent); font-size: 10px; font-weight: 800; }
.person-result.unsafe span { color: var(--danger); }
.person-result.unknown span { color: var(--warning); }
.person-result p, .people-empty { margin: 0; font-size: 12px; line-height: 1.5; }
.people-empty { padding: 12px 0; color: var(--muted); }

.output-section { margin-top: 56px; }
.section-title { margin-bottom: 20px; }
.section-title p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.image-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.image-compare.single { grid-template-columns: 1fr; }
.image-compare figure[hidden] { display: none; }
.image-compare figure { margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: var(--shadow); }
.image-compare figcaption { padding: 2px 2px 12px; color: var(--muted); font-size: 12px; }
.image-compare figcaption span { margin-right: 8px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: 0.12em; }
.image-stage {
    width: 100%;
    min-height: 320px;
    max-height: 720px;

    display: flex;
    justify-content: center;
    align-items: center;

    overflow: hidden;
    border-radius: 10px;

    background: #eef2f0;
}


.image-stage img {
    width: 100%;
    height: auto;

    max-height: 700px;

    object-fit: contain;

    display: block;
}

.json-panel { margin-top: 22px; overflow: hidden; border: 1px solid #26352f; border-radius: 16px; background: #14211c; box-shadow: var(--shadow); }
.json-heading { min-height: 52px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #2c3d36; }
.json-heading > div { display: flex; align-items: center; gap: 9px; }
.code-dot { width: 7px; height: 7px; border-radius: 50%; background: #65ca9b; box-shadow: 0 0 0 4px rgba(101, 202, 155, 0.1); }
.json-heading h3 { margin: 0; color: #d7e4de; font-size: 12px; font-weight: 600; }
.copy-button { padding: 7px 11px; border: 1px solid #3b4d45; border-radius: 7px; background: #1d2d26; color: #c7d5cf; cursor: pointer; font-size: 11px; }
.copy-button:hover { border-color: #6a8177; }
.json-panel pre { margin: 0; padding: 22px; overflow: auto; color: #b9e9d2; font: 12px/1.75 "SFMono-Regular", Consolas, monospace; }

footer { min-height: 72px; padding: 0 max(20px, calc((100vw - 1180px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); background: white; color: #7a8580; font-size: 11px; }

@media (max-width: 900px) {
  .hero { align-items: flex-start; flex-direction: column; }
  .pipeline { align-self: stretch; justify-content: center; }
  .workspace, .image-compare { grid-template-columns: 1fr; }
  .panel { min-height: auto; }
}

@media (max-width: 560px) {
  .topbar { height: 60px; padding: 0 18px; }
  .page-shell { width: min(100% - 28px, 1180px); padding-top: 42px; }
  .hero { gap: 28px; }
  .pipeline { gap: 6px; overflow-x: auto; justify-content: flex-start; }
  .pipeline i { width: 12px; }
  .panel { padding: 20px; }
  .panel-heading { flex-direction: column; }
  .settings-grid { grid-template-columns: 1fr; }
  .setting-toggles { grid-column: auto; flex-direction: column; gap: 10px; }
  .image-stage {
    min-height: 220px;
    max-height: 520px;
}
  footer { align-items: flex-start; flex-direction: column; padding-top: 20px; padding-bottom: 20px; }
}

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