:root {
  --ink: #16221f;
  --muted: #6c7974;
  --line: #dce5df;
  --paper: #f4f7f4;
  --panel: #ffffff;
  --forest: #1d4a3a;
  --forest-dark: #123228;
  --teal: #27887d;
  --coral: #cc604e;
  --amber: #c08a2e;
  --soft-green: #e9f1ec;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}
a { color: inherit; }
button, select, input { font: inherit; }

.site-header {
  min-height: 68px;
  padding: 0 clamp(18px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--forest-dark);
  color: #f5faf7;
}
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 1px solid #91c2ae; color: #cce9dc; font-weight: 800; font-size: 15px;
}
.brand strong { display: block; font-size: 15px; letter-spacing: .04em; }
.brand small { display: block; margin-top: 1px; color: #a8cbbd; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; }
.header-meta { display: flex; align-items: center; gap: 8px; color: #bad9cc; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #7ed7a6; box-shadow: 0 0 0 3px rgba(126, 215, 166, .14); }

.page-shell { width: min(1220px, calc(100% - 40px)); margin: 0 auto; padding: 38px 0 54px; }
.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; padding: 0 2px 30px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 8px; color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 720px; margin-bottom: 9px; color: var(--forest-dark); font-size: clamp(30px, 5vw, 52px); line-height: 1.08; letter-spacing: -.02em; }
.intro-copy { max-width: 650px; margin-bottom: 0; color: var(--muted); font-size: 15px; }
.intro-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 11px; min-width: 230px; }
.quiet-link, .text-link { color: var(--forest); font-size: 13px; font-weight: 700; text-decoration: none; }
.quiet-link:hover, .text-link:hover { color: var(--coral); }
.model-note { color: var(--muted); font-size: 12px; text-align: right; }

.workspace { display: grid; grid-template-columns: minmax(240px, 285px) minmax(0, 1fr); gap: 22px; margin-top: 24px; }
.control-panel, .preview-panel { background: var(--panel); border: 1px solid var(--line); }
.control-panel { padding: 22px; }
.panel-heading { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.panel-heading h2, .preview-heading h2 { margin-bottom: 0; color: var(--forest-dark); font-size: 20px; }
.field-label { display: block; margin: 17px 0 8px; color: var(--ink); font-size: 12px; font-weight: 700; }
.field-row { display: flex; align-items: center; justify-content: space-between; }
.field-row .field-label { margin-bottom: 8px; }
output { color: var(--teal); font-size: 12px; font-variant-numeric: tabular-nums; }
.select-control {
  width: 100%; min-height: 40px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 4px; background: #fbfcfb; color: var(--ink); outline: none;
}
.select-control:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(39, 136, 125, .12); }
.range-control { width: 100%; height: 4px; accent-color: var(--teal); cursor: pointer; }
.upload-zone {
  min-height: 128px; margin-top: 20px; padding: 18px 12px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; border: 1px dashed #a9c6b8;
  border-radius: 5px; background: #f7fbf8; color: var(--forest); text-align: center; cursor: pointer;
}
.upload-zone:hover, .upload-zone.is-dragover { border-color: var(--teal); background: var(--soft-green); }
.upload-zone input { display: none; }
.upload-icon { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid #93b8a9; font-size: 21px; line-height: 1; }
.upload-zone strong { font-size: 13px; }
.upload-zone small { color: var(--muted); font-size: 11px; }
.file-line { min-height: 18px; margin-top: 8px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.button-stack { display: grid; gap: 9px; margin-top: 15px; }
.button {
  min-height: 42px; border: 1px solid transparent; border-radius: 4px; cursor: pointer;
  font-size: 13px; font-weight: 800; transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .43; cursor: not-allowed; }
.button.primary { background: var(--forest); color: white; }
.button.primary:hover:not(:disabled) { background: var(--forest-dark); }
.button.secondary { border-color: var(--line); background: #fff; color: var(--forest); }
.button.secondary:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.engine-status { min-height: 33px; margin-top: 16px; padding: 8px 10px; display: flex; align-items: center; gap: 8px; background: #f5f8f6; color: var(--muted); font-size: 11px; }
.status-light { width: 7px; height: 7px; border-radius: 50%; background: #a9b7b1; flex: 0 0 auto; }
.engine-status[data-kind="working"] .status-light { background: var(--amber); animation: pulse 1s infinite; }
.engine-status[data-kind="success"] .status-light { background: var(--teal); }
.engine-status[data-kind="error"] .status-light { background: var(--coral); }
@keyframes pulse { 50% { opacity: .35; } }
.disclaimer { margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--line); }
.disclaimer strong { color: var(--coral); font-size: 11px; letter-spacing: .08em; }
.disclaimer p { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }

.preview-panel { min-width: 0; padding: 22px; }
.preview-heading, .result-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.mode-badge { padding: 5px 8px; border: 1px solid #b8d8ca; color: var(--teal); font-size: 10px; font-weight: 800; letter-spacing: .11em; }
.canvas-frame { min-height: 420px; margin-top: 18px; display: grid; place-items: center; overflow: hidden; background: #edf1ee; border: 1px solid var(--line); transition: border-color .18s ease, background .18s ease; }
.canvas-frame.has-result { min-height: 0; }
.canvas-frame.is-dragover { border-color: var(--teal); background: var(--soft-green); }
#resultCanvas { display: block; max-width: 100%; height: auto; }
.empty-state { min-height: 420px; width: 100%; padding: 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); font-size: 14px; }
.empty-state span { font-size: 12px; }
.empty-symbol { width: 44px; height: 44px; margin-bottom: 2px; display: grid; place-items: center; border: 1px solid #b8c8c0; color: var(--teal); font-size: 24px; }
.sample-heading { margin-top: 12px; color: var(--ink); font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.sample-grid { display: grid; grid-template-columns: repeat(2, minmax(120px, 160px)); gap: 10px; margin-top: 2px; }
.sample-card { padding: 0 0 8px; overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink); cursor: pointer; text-align: left; }
.sample-card:hover { border-color: var(--teal); box-shadow: 0 3px 10px rgba(29, 74, 58, .1); }
.sample-card img { display: block; width: 100%; aspect-ratio: 1.7 / 1; object-fit: cover; }
.sample-card span { display: block; padding: 7px 9px 0; color: var(--forest); font-size: 11px; font-weight: 800; }
.empty-hint { margin-top: 3px; color: var(--muted); font-size: 10px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 14px; border: 1px solid var(--line); }
.stat-item { min-height: 66px; padding: 12px 14px; border-right: 1px solid var(--line); }
.stat-item:last-child { border-right: 0; }
.stat-item span { display: block; color: var(--muted); font-size: 11px; }
.stat-item strong { display: block; margin-top: 3px; color: var(--forest-dark); font-size: 22px; font-variant-numeric: tabular-nums; }
.fire-stat strong { color: var(--coral); }
.result-heading { margin-top: 25px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.result-heading h3 { margin-bottom: 0; color: var(--forest-dark); font-size: 17px; }
.result-caption { color: var(--muted); font-size: 11px; }
.result-list { min-height: 56px; }
.result-empty { padding: 18px 4px; color: var(--muted); font-size: 12px; }
.result-row { display: grid; grid-template-columns: 10px minmax(70px, 1fr) 80px minmax(110px, 1fr); gap: 10px; align-items: center; padding: 11px 4px; border-bottom: 1px solid #edf1ee; font-size: 12px; }
.result-row:last-child { border-bottom: 0; }
.result-swatch { width: 4px; height: 26px; background: var(--teal); }
.result-row.fire .result-swatch { background: var(--coral); }
.result-name { color: var(--ink); font-weight: 800; }
.result-confidence { color: var(--teal); font-variant-numeric: tabular-nums; }
.result-row.fire .result-confidence { color: var(--coral); }
.result-box { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }

.info-strip { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; margin-top: 22px; padding: 24px 25px; border: 1px solid var(--line); background: var(--soft-green); }
.info-strip article + article { padding-left: 24px; border-left: 1px solid #cddfd4; }
.info-strip h2 { margin-bottom: 7px; color: var(--forest-dark); font-size: 18px; }
.info-strip p { max-width: 660px; margin-bottom: 0; color: #587168; font-size: 12px; line-height: 1.75; }
.text-link { display: inline-block; margin-top: 12px; }
.site-footer { width: min(1220px, calc(100% - 40px)); margin: 0 auto; padding: 0 0 30px; display: flex; justify-content: space-between; gap: 14px; color: var(--muted); font-size: 11px; }

@media (max-width: 850px) {
  .intro { align-items: flex-start; flex-direction: column; }
  .intro-actions { align-items: flex-start; }
  .model-note { text-align: left; }
  .workspace { grid-template-columns: 1fr; }
  .canvas-frame, .empty-state { min-height: 300px; }
  .sample-grid { grid-template-columns: repeat(2, minmax(110px, 145px)); }
  .info-strip { grid-template-columns: 1fr; }
  .info-strip article + article { padding-left: 0; padding-top: 20px; border-top: 1px solid #cddfd4; border-left: 0; }
}
@media (max-width: 520px) {
  .page-shell { width: min(100% - 24px, 1220px); padding-top: 25px; }
  .site-header { padding: 0 14px; }
  .header-meta { font-size: 10px; }
  .header-meta span:last-child { display: none; }
  .control-panel, .preview-panel { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-item:nth-child(2) { border-right: 0; }
  .stat-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .result-row { grid-template-columns: 8px minmax(62px, 1fr) 64px; }
  .result-box { grid-column: 2 / -1; }
  .sample-grid { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .site-footer { width: calc(100% - 24px); flex-direction: column; }
}
