:root {
  --ink: #171716;
  --muted: #6f6f68;
  --line: #d9d9d2;
  --paper: #fbfbf7;
  --panel: #f0f0e9;
  --accent: #f3b326;
  --accent-soft: #fff2cc;
  --danger: #a53b2f;
  --success: #28724c;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 251, 247, .94);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-weight: 850; letter-spacing: -.03em; font-size: 18px; }
.brand i { font-style: normal; color: var(--muted); font-weight: 620; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: var(--accent); background: var(--ink); font-size: 21px; }
.privacy-pill { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; }
.privacy-pill span { width: 7px; height: 7px; border-radius: 50%; background: #39a76e; box-shadow: 0 0 0 3px #d8f0e2; }

main { width: min(1460px, 100%); margin: 0 auto; }
.hero { padding: clamp(72px, 9vw, 124px) clamp(20px, 5vw, 78px) clamp(58px, 7vw, 92px); border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 18px; color: #9c7213; font-size: 11px; font-weight: 850; letter-spacing: .16em; }
.hero h1 { margin: 0; max-width: 880px; font-size: clamp(49px, 7vw, 104px); line-height: .91; letter-spacing: -.065em; font-weight: 890; }
.hero > p:last-child { max-width: 670px; margin: 30px 0 0; color: var(--muted); font-size: clamp(17px, 2vw, 21px); line-height: 1.55; }

.workflow { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.step-card { min-width: 0; padding: clamp(26px, 3vw, 44px); border-right: 1px solid var(--line); }
.step-card:last-child { border-right: 0; }
.step-head { display: flex; align-items: flex-start; gap: 15px; min-height: 58px; margin-bottom: 24px; }
.step-head > span { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 auto; border-radius: 8px; color: var(--accent); background: var(--ink); font-size: 11px; font-weight: 900; }
.step-head h2 { margin: -2px 0 5px; font-size: 21px; letter-spacing: -.035em; }
.step-head p { margin: 0; color: var(--muted); font-size: 12px; }

.asset-card { width: 100%; display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 12px; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 13px; transition: .18s ease; }
.asset-card:hover { border-color: #b79a59; transform: translateY(-1px); box-shadow: 0 9px 22px rgba(23,23,22,.07); }
.asset-thumb { width: 72px; height: 52px; display: grid; place-items: center; overflow: hidden; border-radius: 8px; background: #ddd; }
.asset-thumb img { width: 100%; height: 100%; object-fit: contain; }
.asset-copy { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.asset-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.asset-copy small, .microcopy { color: var(--muted); font-size: 10px; line-height: 1.5; }
.replace { color: #8e6712; font-size: 11px; font-weight: 800; }
.microcopy { margin: 12px 3px 0; }

.segment { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #e9e9e2; }
.segment button { min-height: 34px; padding: 6px 10px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 760; }
.segment button.is-active { color: var(--ink); background: #fff; box-shadow: 0 1px 5px rgba(23,23,22,.12); }
.control-stack { margin-top: 16px; }
label { display: flex; min-width: 0; flex-direction: column; gap: 7px; font-size: 11px; font-weight: 760; color: #55554f; }
input, select { width: 100%; min-width: 0; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: #fff; font-size: 12px; }
input:focus, select:focus { border-color: #b38418; box-shadow: 0 0 0 3px rgba(243,179,38,.18); }
.unit-input { display: flex; align-items: center; min-width: 0; overflow: hidden; height: 38px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.unit-input:focus-within { border-color: #b38418; box-shadow: 0 0 0 3px rgba(243,179,38,.18); }
.unit-input input { height: 36px; border: 0; box-shadow: none; }
.unit-input input:focus { box-shadow: none; }
.unit-input em { padding: 0 10px; color: var(--muted); font-size: 11px; font-style: normal; white-space: nowrap; }
.field-grid { display: grid; gap: 12px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compact-fields { margin: 16px 0 12px; }
.basis-row { display: grid; grid-template-columns: auto minmax(170px, 1fr); align-items: center; gap: 12px; margin-top: 14px; color: var(--muted); font-size: 11px; }
.formula-box { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-top: 16px; padding: 13px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); }
.formula-box small { flex-basis: 100%; color: #88620f; font-size: 9px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.formula-box strong { font-size: 13px; }
.formula-box span { color: #755f2e; font-size: 10px; }

.candidate-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.candidate { min-width: 0; padding: 10px 3px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.candidate span, .candidate strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.candidate span { color: var(--muted); font-size: 9px; font-weight: 750; }
.candidate strong { margin-top: 5px; font-size: 10px; }
.candidate.is-active { border-color: var(--ink); color: var(--accent); background: var(--ink); box-shadow: 0 0 0 2px rgba(243,179,38,.25); }
.candidate.is-active span { color: #e7e0d1; }
.candidate-help { margin: 11px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.proof-note { margin-top: 16px; padding: 12px; border-radius: 10px; color: #66583a; background: #f1ecdf; font-size: 10px; line-height: 1.5; }
.proof-note b { color: var(--ink); }
.check-row { flex-direction: row; align-items: flex-start; gap: 9px; margin-top: 10px; font-size: 10px; line-height: 1.4; }
.check-row input { width: 15px; height: 15px; padding: 0; margin: 0; accent-color: var(--ink); }

.output-stage { display: grid; grid-template-columns: minmax(300px, .78fr) minmax(540px, 1.22fr); min-height: 760px; }
.stage-copy { padding: clamp(42px, 5vw, 76px); border-right: 1px solid var(--line); background: #ecece5; }
.stage-copy h2 { margin: 0 0 25px; font-size: clamp(36px, 4vw, 59px); line-height: .98; letter-spacing: -.055em; }
.stage-copy > .segment { margin-bottom: 22px; }
.mode-explain { display: flex; gap: 15px; padding: 17px; border: 1px solid #d5d5cd; border-radius: 13px; background: rgba(255,255,255,.62); }
.mode-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 auto; border-radius: 10px; color: var(--accent); background: var(--ink); font-size: 18px; }
.mode-explain strong { font-size: 13px; }
.mode-explain p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.settings-block { margin-top: 28px; padding-top: 25px; border-top: 1px solid #cecec6; }
.warning { display: flex; flex-direction: column; gap: 5px; margin-top: 24px; padding: 14px; border-radius: 11px; font-size: 11px; line-height: 1.45; }
.warning strong { font-size: 12px; }
.warning.info { color: #66531e; background: #fff1c9; }
.warning.success { color: #245b3f; background: #dfeee5; }
.warning.danger { color: #7d2e27; background: #f3deda; }

.sheet-panel { min-width: 0; display: flex; flex-direction: column; padding: clamp(28px, 4vw, 58px); background: #20201e; color: #fff; }
.sheet-toolbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 22px; }
.sheet-toolbar > div:first-child { display: flex; flex-direction: column; gap: 5px; }
.sheet-toolbar strong { font-size: 14px; }
.sheet-toolbar span { color: #aaa9a1; font-size: 10px; }
.page-nav { display: flex; align-items: center; gap: 10px; }
.page-nav button { width: 30px; height: 30px; border: 1px solid #44443f; border-radius: 8px; color: #fff; background: #2b2b28; }
.page-nav button:disabled { opacity: .28; cursor: default; }
.canvas-wrap { flex: 1; min-height: 460px; display: grid; place-items: center; overflow: auto; padding: clamp(18px, 3vw, 42px); border-radius: 13px; background: #141413; box-shadow: inset 0 0 0 1px #2f2f2b; }
#sheetCanvas { display: block; max-width: 100%; max-height: 660px; width: auto; height: auto; box-shadow: 0 16px 42px rgba(0,0,0,.38); }
.export-row { display: grid; grid-template-columns: 1.4fr .7fr 1fr; gap: 9px; margin-top: 18px; }
.export-row button { min-height: 42px; border: 1px solid #454540; border-radius: 9px; color: #eee; background: #2b2b28; font-size: 11px; font-weight: 780; }
.export-row button:hover { border-color: #77776e; }
.export-row .primary { border-color: var(--accent); color: #171716; background: var(--accent); }
.status { min-height: 16px; margin: 12px 2px 0; color: #999990; font-size: 10px; }

.validation-section { display: grid; grid-template-columns: minmax(320px, .82fr) minmax(420px, 1.18fr); border-top: 1px solid var(--line); background: var(--accent); }
.validation-section > div { padding: clamp(42px, 5vw, 76px); }
.validation-section > div:first-child { border-right: 1px solid rgba(23,23,22,.25); }
.validation-section .eyebrow { color: #5d4309; }
.validation-section h2 { margin: 0; font-size: clamp(37px, 4.6vw, 70px); line-height: .96; letter-spacing: -.055em; }
.validation-copy { display: flex; flex-direction: column; justify-content: center; }
.validation-copy > p:first-child { max-width: 650px; margin: 0 0 24px; font-size: clamp(15px, 1.7vw, 19px); line-height: 1.55; }
.feedback-button { width: min(100%, 460px); display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 54px; padding: 0 18px; border: 1px solid var(--ink); border-radius: 10px; color: #fff; background: var(--ink); font-size: 12px; font-weight: 820; }
.feedback-button:hover { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(23,23,22,.18); }
.feedback-button b { color: var(--accent); font-size: 10px; }
.feedback-status { min-height: 16px; margin: 11px 2px 0; color: #5d4309; font-size: 10px; }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 24px clamp(20px, 4vw, 64px); border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; letter-spacing: .04em; }

@media (max-width: 1120px) {
  .workflow { grid-template-columns: 1fr; }
  .step-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .step-card:last-child { border-bottom: 0; }
  .output-stage { grid-template-columns: 1fr; }
  .stage-copy { border-right: 0; border-bottom: 1px solid var(--line); }
  .validation-section { grid-template-columns: 1fr; }
  .validation-section > div:first-child { border-right: 0; border-bottom: 1px solid rgba(23,23,22,.25); }
}

@media (max-width: 640px) {
  .topbar { height: 62px; padding: 0 16px; }
  .brand { font-size: 16px; }
  .brand-mark { width: 31px; height: 31px; }
  .privacy-pill { padding: 7px 8px; font-size: 8px; letter-spacing: .05em; }
  .hero { padding: 62px 20px 50px; }
  .hero h1 { font-size: clamp(44px, 14vw, 62px); }
  .hero > p:last-child { margin-top: 22px; font-size: 16px; }
  .step-card { padding: 28px 20px; }
  .asset-card { grid-template-columns: 62px minmax(0, 1fr); }
  .asset-thumb { width: 62px; height: 48px; }
  .replace { display: none; }
  .field-grid.three { grid-template-columns: 1fr; }
  .candidate-grid { gap: 3px; }
  .candidate { padding: 9px 1px; }
  .candidate strong { font-size: 8px; }
  .basis-row { grid-template-columns: 1fr; }
  .stage-copy, .sheet-panel, .validation-section > div { padding: 38px 20px; }
  .canvas-wrap { min-height: 400px; padding: 16px; }
  .sheet-toolbar { align-items: flex-end; }
  .sheet-toolbar > div:first-child { min-width: 0; }
  .sheet-toolbar span { overflow-wrap: anywhere; }
  .export-row { grid-template-columns: 1fr; }
  footer { flex-direction: column; padding: 22px 20px; }
}

@media print {
  body > * { display: none !important; }
}
