:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #172b3f;
  --muted: #647487;
  --line: #d7dee6;
  --line-strong: #aebbc8;
  --action: #2868b2;
  --action-hover: #1f5797;
  --photo-blue: #438edb;
  --photo-red: #d93b43;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

.svg-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: square; stroke-linejoin: miter; }

.site-header,
main,
.site-footer { width: 100%; max-width: 1240px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }

.site-header { height: 58px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: var(--surface); }
body::before { content: ""; position: absolute; z-index: -1; top: 0; left: 0; right: 0; height: 58px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 700; }
.brand-mark { display: grid; grid-template-columns: repeat(3, 6px); gap: 2px; height: 22px; }
.brand-mark i { display: block; width: 6px; height: 22px; background: var(--line-strong); }
.brand-mark i:nth-child(2) { background: var(--photo-blue); }
.brand-mark i:nth-child(3) { background: var(--photo-red); }
.header-note { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; }
.header-note .icon { width: 15px; height: 15px; }

main { padding-top: 22px; }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
h1 { margin: 0; font-size: 23px; line-height: 1.25; letter-spacing: -.5px; }
.page-title p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.page-title > span { display: none; color: var(--muted); font-size: 11px; white-space: nowrap; }

.notice { margin: 0 0 12px; padding: 11px 12px; border: 1px solid #dcc589; background: #fff8e6; color: #715313; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.notice-error { border-color: #e0b9bd; background: #fff2f3; color: #8c2d39; }

.workspace { border: 1px solid var(--line); background: var(--surface); }
.upload-panel,
.results-panel { padding: 18px; }
.upload-panel { border-bottom: 1px solid var(--line); }
.section-heading,
.results-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h2 { margin: 0; font-size: 15px; font-weight: 700; }
.section-heading > span,
.overall-status { color: var(--muted); font-size: 10px; white-space: nowrap; }

.upload-area { position: relative; display: block; width: 100%; height: 210px; margin: 16px 0 0; padding: 0; overflow: hidden; border: 1px dashed var(--line-strong); border-radius: 0; color: var(--ink); background: #f8fafc; }
.upload-area:not(:disabled):hover,
.upload-area.dragging { border-style: solid; border-color: var(--action); background: #edf4fb; }
.upload-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; }
.upload-symbol { display: grid; place-items: center; width: 40px; height: 40px; color: var(--action); border: 1px solid #c9d7e6; background: var(--surface); }
.upload-empty strong { font-size: 13px; font-weight: 600; }
.upload-empty small { color: var(--muted); font-size: 10px; }
#source-image { display: block; width: 100%; height: 100%; object-fit: contain; background: #edf1f5; }
.replace-label { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 10px; color: #fff; background: #172b3fe6; font-size: 10px; text-align: center; }
.file-info { margin: 9px 0 15px; color: var(--muted); font-size: 10px; line-height: 1.6; overflow-wrap: anywhere; }
.consent { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 11px; line-height: 1.7; cursor: pointer; }
.consent input { flex: 0 0 auto; width: 16px; height: 16px; margin: 1px 0 0; border-radius: 0; accent-color: var(--action); }
.consent strong { color: var(--ink); font-weight: 600; }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px; margin-top: 14px; border: 1px solid var(--action); border-radius: 0; background: var(--action); color: #fff; font-size: 13px; font-weight: 600; }
.primary-button:not(:disabled):hover { border-color: var(--action-hover); background: var(--action-hover); }
.primary-button:disabled { border-color: #dce2e8; background: #e9edf1; color: #8390a0; }
.primary-button.busy .icon { animation: pulse 1.2s infinite; }
.generation-note { margin: 8px 0 0; color: var(--muted); font-size: 9px; text-align: center; }
.privacy-note { display: flex; align-items: center; gap: 7px; margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); color: var(--muted); }
.privacy-note .icon { width: 15px; height: 15px; color: var(--action); }
.privacy-note p { margin: 0; font-size: 10px; line-height: 1.5; }

.results-heading { margin-bottom: 18px; }
.photo-grid { display: grid; gap: 20px; }
.photo-card { display: grid; grid-template-columns: minmax(118px, 43%) 1fr; grid-template-rows: auto 1fr auto; gap: 10px 14px; min-width: 0; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.photo-card:last-child { padding-bottom: 0; border-bottom: 0; }
.photo-title { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.photo-title h3 { display: flex; align-items: center; gap: 7px; margin: 0; font-size: 13px; font-weight: 600; }
.photo-state { color: var(--muted); font-size: 10px; }
.color-dot { display: block; width: 9px; height: 9px; border-radius: 50%; }
.white-dot { border: 1px solid var(--line-strong); background: #fff; }
.blue-dot { background: var(--photo-blue); }
.red-dot { background: var(--photo-red); }
.photo-frame { grid-column: 1; grid-row: 2 / 4; position: relative; width: 100%; aspect-ratio: 5 / 7; overflow: hidden; border: 1px solid var(--line); border-radius: 0; }
.white-frame { background: #f7f9fb; }
.blue-frame { border-color: #ccdaea; background: #e6effb; }
.red-frame { border-color: #ead3d6; background: #f9e9eb; }
.placeholder { display: block; width: 100%; height: 100%; }
.portrait-head { fill: #d9e0e7; }
.portrait-shoulders { fill: #d0d9e3; }
.portrait-guide { fill: none; stroke: #9caec0; stroke-width: 1; opacity: .65; }
.blue-frame .portrait-head { fill: #c5d8ef; }
.blue-frame .portrait-shoulders { fill: #b8d0ec; }
.red-frame .portrait-head { fill: #eccfd4; }
.red-frame .portrait-shoulders { fill: #e6c2c8; }
.result-image { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; background: #edf1f5; }
.frame-message { position: absolute; left: 5px; right: 5px; bottom: 10px; display: flex; align-items: center; justify-content: center; gap: 6px; color: #68788b; font-size: 9px; text-align: center; }
.state-indicator { display: none; width: 10px; height: 10px; border: 1px solid #9aacbe; border-top-color: var(--action); border-radius: 50%; }
.photo-card.processing .state-indicator { display: block; animation: spin 1s linear infinite; }
.photo-card.has-preview .frame-message { display: none; }
.photo-card.failed .photo-state,
.photo-error { color: #a52e3a; }
.download-links { grid-column: 2; grid-row: 2; display: grid; align-content: end; gap: 8px; }
.download-link { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 54px; padding: 9px 10px; border: 1px solid #bfd0e2; color: #245d9f; text-decoration: none; font-size: 11px; }
.download-link small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; white-space: nowrap; }
.download-link .icon { width: 14px; height: 14px; }
.download-link[aria-disabled="true"] { border-color: #e0e5ea; background: #f7f8fa; color: #8a96a3; cursor: not-allowed; }
.download-link[aria-disabled="true"] small { color: #909ba7; }
.download-link[aria-disabled="false"]:hover { background: #edf4fb; }
.photo-error { grid-column: 2; grid-row: 3; align-self: end; margin: 0; font-size: 10px; line-height: 1.5; }
.results-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 19px; padding-top: 14px; border-top: 1px solid var(--line); }
.results-footer p,
.print-note { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.6; }
.text-button { padding: 5px 0; border: 0; border-radius: 0; background: transparent; color: var(--muted); font-size: 10px; text-decoration: underline; text-underline-offset: 3px; }
.text-button:disabled { opacity: .45; text-decoration: none; }
.print-note { margin-top: 9px; }

.site-footer { padding-top: 17px; padding-bottom: 22px; color: var(--muted); font-size: 9px; line-height: 1.7; }
.toast { position: fixed; z-index: 5; left: 16px; right: 16px; bottom: 16px; padding: 12px 14px; border-radius: 0; background: var(--ink); color: #fff; box-shadow: 0 6px 20px #172b3f24; font-size: 11px; line-height: 1.5; text-align: center; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }

@media (min-width: 600px) {
  .site-header,
  main,
  .site-footer { padding-left: 24px; padding-right: 24px; }
  main { padding-top: 26px; }
  .page-title > span { display: block; }
  .upload-panel,
  .results-panel { padding: 24px; }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .photo-card { display: block; padding-bottom: 0; border-bottom: 0; }
  .photo-title { margin-bottom: 10px; }
  .photo-frame { width: 100%; }
  .download-links { grid-template-columns: 1fr; margin-top: 10px; }
  .photo-error { margin-top: 8px; }
  .toast { left: 50%; right: auto; min-width: 320px; max-width: 560px; transform: translateX(-50%); }
}

@media (min-width: 960px) {
  .site-header { height: 64px; }
  body::before { height: 64px; }
  main { padding-top: 32px; }
  .page-title { margin-bottom: 22px; }
  h1 { font-size: 27px; }
  .workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr); }
  .upload-panel { border-right: 1px solid var(--line); border-bottom: 0; }
  .upload-area { height: 244px; }
  .results-panel { padding: 24px 28px; }
  .photo-grid { gap: 20px; }
  .download-links { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .download-link { min-height: 52px; padding: 8px; }
  .download-link .icon { display: none; }
}

@media (min-width: 1180px) {
  .site-header,
  main,
  .site-footer { padding-left: 32px; padding-right: 32px; }
  .workspace { grid-template-columns: 320px minmax(0, 1fr); }
  .upload-panel,
  .results-panel { padding: 28px; }
  .results-panel { padding-left: 34px; padding-right: 34px; }
  .photo-grid { gap: 24px; }
  .download-link .icon { display: block; }
}

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