:root {
  --paper: #f4f6f2;
  --surface: #ffffff;
  --ink: #17201b;
  --muted: #69736d;
  --line: #d9dfda;
  --line-strong: #b9c3bc;
  --coral: #e4573d;
  --coral-dark: #bd3f2a;
  --green: #26705c;
  --green-soft: #dcebe5;
  --gold: #d9a928;
  --gold-soft: #f4e8bc;
  --danger: #b8322d;
  --shadow: 0 16px 44px rgba(23, 32, 27, 0.08);
  color-scheme: light;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.55;
}

body.modal-open { overflow: hidden; }

button, input { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

button { letter-spacing: 0; }

a { color: inherit; text-decoration: none; }

[hidden] { display: none !important; }

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 10px max(22px, calc((100vw - 1360px) / 2));
  border-bottom: 1px solid rgba(185, 195, 188, 0.8);
  background: rgba(244, 246, 242, 0.94);
  backdrop-filter: blur(14px);
}

.brand { display: inline-flex; align-items: center; gap: 11px; }

.brand-mark {
  display: grid;
  grid-template-columns: repeat(4, 4px);
  align-items: center;
  gap: 3px;
  width: 36px;
  height: 36px;
  padding: 7px;
  color: var(--surface);
  background: var(--ink);
  border-radius: 6px;
}

.brand-mark i { display: block; height: 12px; background: currentColor; border-radius: 2px; }
.brand-mark i:nth-child(2) { height: 20px; color: var(--coral); }
.brand-mark i:nth-child(3) { height: 16px; color: var(--gold); }
.brand-mark i:nth-child(4) { height: 9px; }

.brand-copy { display: grid; line-height: 1.08; }
.brand-copy strong { font-size: 17px; }
.brand-copy em { margin-top: 4px; color: var(--muted); font: 700 9px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }

.account-bar { display: flex; align-items: center; gap: 8px; }

.credit-badge, .status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.button, .icon-button, .stem-button, .segment, .package-grid button, .download-chip, .history-row {
  border: 0;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 6px;
  font-weight: 800;
  transition: transform 150ms ease, color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: 0.45; }
.button-quiet { border: 1px solid var(--line); color: var(--ink); background: var(--surface); }
.button-quiet:hover:not(:disabled) { border-color: var(--line-strong); }
.button-accent { color: var(--surface); background: var(--coral); }
.button-accent:hover:not(:disabled) { background: var(--coral-dark); }
.button-primary { min-width: 210px; color: var(--surface); background: var(--ink); }
.button-primary:hover:not(:disabled) { background: var(--green); }

.button.is-loading::after {
  width: 14px;
  height: 14px;
  margin-left: 9px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  content: "";
  animation: spin 700ms linear infinite;
}

main { width: min(1360px, calc(100% - 44px)); margin: 0 auto; }

.workbench { min-height: calc(100vh - 72px); padding: 36px 0 38px; }

.workbench-heading, .section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow, .section-heading p, .console-head p {
  margin: 0 0 6px;
  color: var(--coral);
  font: 800 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
}

h1, h2, p { letter-spacing: 0; }

h1 { margin: 0; font-size: 52px; line-height: 1; }

.lede { max-width: 650px; margin: 12px 0 0; color: var(--muted); font-size: 18px; }

.engine-facts { display: flex; margin: 0; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.engine-facts div { min-width: 112px; padding: 10px 14px; border-left: 1px solid var(--line); }
.engine-facts div:first-child { border-left: 0; }
.engine-facts dt { color: var(--muted); font-size: 10px; font-weight: 800; }
.engine-facts dd { margin: 2px 0 0; font-size: 13px; font-weight: 800; }

.work-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, 0.75fr); gap: 18px; margin-top: 30px; }

.input-console, .task-console {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.input-console { padding: 24px; }
.task-console { display: flex; flex-direction: column; min-height: 530px; padding: 22px; background: var(--ink); color: var(--surface); }

.mode-row, .stem-picker { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.stem-picker { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.field-title { padding-top: 9px; color: var(--muted); font-size: 12px; font-weight: 800; white-space: nowrap; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; width: min(100%, 430px); padding: 4px; border: 1px solid var(--line); background: var(--paper); }
.segment { min-height: 38px; padding: 0 13px; color: var(--muted); background: transparent; font-weight: 800; }
.segment.is-active { color: var(--surface); background: var(--ink); }

.stem-grid { display: grid; grid-template-columns: repeat(7, minmax(62px, 1fr)); gap: 6px; width: min(100%, 620px); }
.stem-button { min-height: 38px; padding: 0 8px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); font-size: 12px; font-weight: 800; }
.stem-button.is-active { border-color: var(--green); color: var(--green); background: var(--green-soft); }

.upload-zone {
  display: grid;
  place-items: center;
  min-height: 176px;
  margin-top: 22px;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  background: var(--paper);
  cursor: pointer;
  text-align: center;
  transition: border-color 150ms ease, background 150ms ease;
}

.upload-zone:hover, .upload-zone.is-dragging { border-color: var(--coral); background: #fff8f5; }
.upload-zone input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.upload-zone strong { margin-top: 5px; font-size: 17px; overflow-wrap: anywhere; }
.upload-zone span:not(.upload-symbol) { color: var(--muted); font-size: 12px; }
.upload-zone small { color: var(--green); font-weight: 800; }
.upload-symbol { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: var(--surface); background: var(--coral); font-size: 24px; line-height: 1; }

.waveform-panel { position: relative; margin-top: 14px; border: 1px solid var(--line); overflow: hidden; background: #fbfcfa; }
.file-facts { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.file-facts > div { display: grid; min-width: 0; }
.file-facts strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-facts span { color: var(--muted); font-size: 11px; }
.icon-button { display: inline-grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: var(--surface); font-weight: 900; }
.icon-button:hover:not(:disabled) { border-color: var(--coral); color: var(--coral); }
#waveformCanvas { display: block; width: 100%; height: 138px; }
.wave-labels { position: absolute; inset: 56px 10px auto; display: flex; justify-content: space-between; color: rgba(23, 32, 27, 0.35); font: 800 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; pointer-events: none; }

.consent-row { display: flex; align-items: flex-start; gap: 9px; margin-top: 16px; color: var(--muted); font-size: 13px; cursor: pointer; }
.consent-row input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--green); }
.submit-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 18px; }
.charge-copy { display: grid; text-align: right; }
.charge-copy span { color: var(--muted); font-size: 11px; }
.form-message { min-height: 22px; margin: 14px 0 0; color: var(--muted); font-size: 12px; }
.form-message.is-error { color: var(--danger); font-weight: 800; }

.console-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid rgba(255,255,255,0.16); }
.console-head h2 { margin: 0; font-size: 21px; }
.status-pill { border-color: rgba(255,255,255,0.2); color: rgba(255,255,255,0.72); background: rgba(255,255,255,0.08); }
.status-pill[data-status="completed"] { border-color: #77c8a9; color: #b9f0dc; }
.status-pill[data-status="failed"] { border-color: #ef8c80; color: #ffc4bd; }

.current-task { display: flex; flex: 1; flex-direction: column; justify-content: center; min-height: 350px; padding: 26px 2px; }
.current-task > strong { margin-top: 18px; font-size: 22px; }
.current-task > span { max-width: 390px; margin-top: 6px; color: rgba(255,255,255,0.62); }
.empty-state { align-items: center; text-align: center; }

.idle-meter, .task-meter { display: flex; align-items: center; justify-content: center; gap: 5px; height: 70px; }
.idle-meter i, .task-meter i { display: block; width: 5px; height: 18px; background: rgba(255,255,255,0.17); }
.idle-meter i:nth-child(2), .idle-meter i:nth-child(6), .task-meter i:nth-child(2), .task-meter i:nth-child(6) { height: 34px; }
.idle-meter i:nth-child(3), .task-meter i:nth-child(3), .task-meter i:nth-child(8) { height: 50px; }
.idle-meter i:nth-child(4), .task-meter i:nth-child(4), .task-meter i:nth-child(7) { height: 62px; }
.idle-meter i:nth-child(5), .task-meter i:nth-child(5) { height: 42px; }
.task-meter { justify-content: flex-start; }
.task-meter i { background: var(--coral); }
.task-meter i:nth-child(even) { background: var(--gold); }
.task-meter.is-active i { animation: meter 1.1s ease-in-out infinite alternate; }
.task-meter.is-active i:nth-child(2n) { animation-delay: -320ms; }
.task-meter.is-active i:nth-child(3n) { animation-delay: -700ms; }

.task-facts { display: grid; grid-template-columns: repeat(3, 1fr); margin: 24px 0 0; border-top: 1px solid rgba(255,255,255,0.16); border-bottom: 1px solid rgba(255,255,255,0.16); }
.task-facts div { padding: 12px 10px; border-left: 1px solid rgba(255,255,255,0.12); }
.task-facts div:first-child { border-left: 0; padding-left: 0; }
.task-facts dt { color: rgba(255,255,255,0.48); font-size: 10px; }
.task-facts dd { margin: 3px 0 0; font: 700 12px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.task-error { margin: 14px 0 0; color: #ffc4bd; font-size: 13px; }
.task-actions { display: flex; justify-content: flex-end; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.16); }
.task-console .button-quiet { border-color: rgba(255,255,255,0.22); color: var(--surface); background: transparent; }

.results-section, .history-section, .seo-band { padding: 46px 0; border-top: 1px solid var(--line-strong); }
.section-heading h2, .seo-band h2 { margin: 0; font-size: 30px; }
.section-heading > span { color: var(--muted); font-size: 12px; }
.result-list, .history-list { display: grid; margin-top: 22px; border-top: 1px solid var(--line-strong); }
.result-row { display: grid; grid-template-columns: minmax(190px, 0.7fr) minmax(240px, 1.2fr) auto; align-items: center; gap: 18px; min-height: 92px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.result-identity { display: flex; align-items: center; gap: 12px; }
.result-identity > div { display: grid; }
.result-identity span { color: var(--muted); font-size: 11px; }
.stem-swatch { display: block; width: 8px; height: 42px; background: var(--green); }
.stem-background { background: var(--coral); }
.stem-bundle { background: var(--gold); }
.result-player { display: flex; align-items: center; min-height: 44px; color: var(--muted); font-size: 12px; }
.result-player audio { width: 100%; height: 38px; }
.result-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.download-chip { min-width: 54px; height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--ink); background: var(--surface); font-size: 11px; font-weight: 900; }
.download-chip:hover:not(:disabled) { border-color: var(--green); color: var(--green); }

.history-row { display: grid; grid-template-columns: 100px minmax(180px, 1fr) minmax(180px, 0.8fr) 24px; align-items: center; gap: 14px; min-height: 66px; padding: 10px 6px; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; }
.history-row:hover { background: rgba(255,255,255,0.6); }
.history-row > span { color: var(--muted); font-size: 12px; }
.history-status { width: max-content; padding: 3px 8px; border-radius: 999px; color: var(--green) !important; background: var(--green-soft); font-weight: 800; }
.history-status[data-status="failed"], .history-status[data-status="cancelled"] { color: var(--danger) !important; background: #f6dedb; }
.history-open { text-align: right; font-size: 26px !important; }
.history-more { margin-top: 16px; }
.empty-history { margin: 0; padding: 28px 4px; color: var(--muted); }

.seo-band { display: grid; grid-template-columns: minmax(250px, 0.7fr) minmax(0, 1.3fr); gap: 52px; }
.seo-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 0.7fr); gap: 32px; }
.seo-columns > p { margin: 0; color: var(--muted); font-size: 16px; }
.seo-columns dl { margin: 0; }
.seo-columns dl div { display: grid; grid-template-columns: 60px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.seo-columns dt { color: var(--muted); font-size: 12px; }
.seo-columns dd { margin: 0; font-weight: 800; }

.site-footer { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px; width: min(1360px, calc(100% - 44px)); min-height: 88px; margin: 0 auto; border-top: 1px solid var(--line-strong); color: var(--muted); font-size: 12px; }
.site-footer > span { color: var(--ink); font-weight: 900; }
.site-footer nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 18px; }
.site-footer a:hover { color: var(--coral); }

.modal { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(23, 32, 27, 0.72); }
.modal-card { position: relative; width: min(540px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 28px; border: 1px solid var(--line-strong); background: var(--surface); box-shadow: 0 24px 70px rgba(0,0,0,0.28); }
.modal-card h2 { margin: 0; font-size: 27px; }
.modal-close { position: absolute; top: 18px; right: 18px; }
.package-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 22px; }
.package-grid button { display: grid; min-height: 82px; padding: 12px; border: 1px solid var(--line); color: var(--ink); background: var(--paper); text-align: left; }
.package-grid button.is-active { border-color: var(--coral); box-shadow: inset 0 -3px var(--coral); }
.package-grid span { margin-top: 6px; color: var(--coral); font-weight: 900; }
.pay-qr { display: grid; place-items: center; margin-top: 18px; padding: 18px; border: 1px solid var(--line); background: var(--paper); }
.pay-qr img { display: block; width: 220px; height: 220px; object-fit: contain; background: #fff; }
.pay-qr span { margin-top: 8px; color: var(--muted); font-size: 12px; }
.modal-message { min-height: 22px; margin: 16px 0 0; color: var(--muted); font-size: 13px; }

:focus-visible { outline: 3px solid rgba(228, 87, 61, 0.4); outline-offset: 3px; }

@keyframes meter { from { transform: scaleY(0.35); opacity: 0.55; } to { transform: scaleY(1); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
  .work-grid { grid-template-columns: 1fr; }
  .task-console { min-height: 430px; }
  .engine-facts { display: none; }
  .seo-band, .seo-columns { grid-template-columns: 1fr; gap: 24px; }
}

@media (max-width: 760px) {
  .app-header { position: static; align-items: flex-start; min-height: 0; padding: 12px 16px; }
  .brand-copy em, .credit-badge, #historyButton { display: none; }
  .account-bar { flex-wrap: wrap; justify-content: flex-end; }
  .button { min-height: 40px; padding: 0 12px; font-size: 13px; }
  main, .site-footer { width: min(100% - 28px, 680px); }
  .workbench { min-height: 0; padding: 28px 0; }
  .workbench-heading { align-items: flex-start; }
  h1 { font-size: 40px; }
  .lede { font-size: 16px; }
  .input-console, .task-console { padding: 16px; }
  .mode-row, .stem-picker { flex-direction: column; gap: 8px; }
  .field-title { padding-top: 0; }
  .segmented { width: 100%; }
  .stem-grid { grid-template-columns: repeat(4, 1fr); width: 100%; }
  .upload-zone { min-height: 155px; padding: 18px 12px; }
  #waveformCanvas { height: 112px; }
  .submit-row { align-items: stretch; flex-direction: column; }
  .button-primary { width: 100%; }
  .charge-copy { text-align: left; }
  .task-console { min-height: 390px; }
  .result-row { grid-template-columns: 1fr auto; gap: 10px; padding: 16px 0; }
  .result-player { grid-column: 1 / -1; grid-row: 2; }
  .history-row { grid-template-columns: 82px 1fr 20px; gap: 9px; }
  .history-row > span:nth-child(3) { grid-column: 2; font-size: 11px; }
  .history-open { grid-column: 3; grid-row: 1 / span 2; }
  .section-heading h2, .seo-band h2 { font-size: 25px; }
  .results-section, .history-section, .seo-band { padding: 34px 0; }
  .package-grid { grid-template-columns: 1fr; }
  .package-grid button { min-height: 62px; }
  .site-footer { grid-template-columns: 1fr; gap: 12px; padding: 24px 0; }
  .site-footer nav { justify-content: flex-start; }
}

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