:root {
  --ink: #153f40;
  --ink-strong: #073c3d;
  --muted: #6c7773;
  --teal: #0d7773;
  --teal-dark: #075d5a;
  --mint: #dceee8;
  --cream: #f7f5ee;
  --paper: #fffefa;
  --line: #d9ddd7;
  --red: #e75f61;
  --shadow: 0 18px 50px rgba(29, 65, 60, 0.11);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(13, 119, 115, .24); outline-offset: 2px; }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 10px max(24px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid rgba(13, 86, 83, .12);
  background: rgba(247, 245, 238, .94);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.brand-mark { display: grid; grid-template-columns: repeat(3, 7px); gap: 2px; padding: 8px; border-radius: 6px; background: var(--teal); }
.brand-mark i { width: 7px; height: 7px; border-radius: 1px; background: white; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4), .brand-mark i:nth-child(6), .brand-mark i:nth-child(8) { opacity: .38; }
.follow-pill { min-height: 38px; padding: 0 16px; color: var(--teal-dark); border: 1px solid rgba(13,119,115,.25); border-radius: 999px; background: var(--paper); font-weight: 700; }

main { overflow: hidden; }
.intro-band {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(480px, 1.2fr);
  align-items: center;
  gap: 56px;
  min-height: 560px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 58px 24px 46px;
}
.eyebrow, .section-kicker { margin: 0 0 14px; color: var(--teal); font-size: 12px; font-weight: 800; letter-spacing: 0; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 24px; color: var(--ink-strong); font-size: clamp(42px, 5.3vw, 72px); line-height: 1.08; letter-spacing: 0; }
.subtitle { max-width: 520px; color: #526460; font-size: 18px; line-height: 1.8; }
.feature-row { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 30px; color: var(--muted); font-size: 14px; }
.feature-row b { color: var(--teal); }
.sample-wrap { position: relative; padding: 20px; border: 1px solid #e4ded0; background: var(--paper); box-shadow: var(--shadow); }
.sample-wrap::before { position: absolute; top: 11px; left: 11px; width: 34px; height: 4px; content: ""; background: var(--teal); }
.sample-wrap canvas { display: block; width: 100%; height: auto; background: white; }
.sample-badge { position: absolute; right: 30px; bottom: 28px; padding: 7px 11px; color: white; border-radius: 4px; background: var(--teal); font-size: 12px; font-weight: 700; }

.workspace { padding: 64px max(24px, calc((100vw - 1240px) / 2)); border-top: 1px solid #dde3dd; border-bottom: 1px solid #dde3dd; background: var(--paper); }
.workspace-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.workspace-heading h2, .palette-section h2 { margin-bottom: 0; color: var(--ink-strong); font-size: 32px; }
.privacy-note { margin: 0; color: var(--muted); font-size: 13px; }

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 330px;
  padding: 40px;
  border: 2px dashed #91b9af;
  background: #f7fbf8;
  transition: border-color .2s, background .2s;
}
.upload-zone.dragging { border-color: var(--teal); background: #edf8f4; }
.upload-icon { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 18px; color: white; border-radius: 50%; background: var(--teal); font-size: 31px; }
.upload-zone strong { font-size: 20px; }
.upload-zone small { margin: 9px 0 22px; color: var(--muted); }
.primary-button, .secondary-button {
  min-height: 48px;
  padding: 0 22px;
  border-radius: 5px;
  font-weight: 800;
  transition: transform .15s, background .15s, box-shadow .15s;
}
.primary-button { color: white; border: 1px solid var(--teal); background: var(--teal); box-shadow: 0 9px 24px rgba(13,119,115,.17); }
.primary-button:hover { background: var(--teal-dark); transform: translateY(-1px); }
.primary-button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.secondary-button { color: var(--teal-dark); border: 1px solid #b9d1ca; background: white; }

.editor { display: grid; grid-template-columns: 300px minmax(0, 1fr); border: 1px solid var(--line); background: #fbfaf6; }
.settings-panel { display: flex; flex-direction: column; gap: 0; padding: 22px; border-right: 1px solid var(--line); background: white; }
.source-thumb { display: grid; grid-template-columns: 70px 1fr; gap: 12px; align-items: center; margin-bottom: 20px; }
.source-thumb img { width: 70px; height: 70px; border: 1px solid var(--line); object-fit: cover; }
.source-thumb strong { display: block; overflow: hidden; max-width: 170px; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.text-button { padding: 5px 0; color: var(--teal); border: 0; background: transparent; font-size: 12px; font-weight: 700; }
fieldset { margin: 0; padding: 20px 0; border: 0; border-top: 1px solid #e8eae5; }
legend { padding: 0; font-size: 14px; font-weight: 800; }
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 14px; border: 1px solid #cfd8d2; }
.segmented button { min-height: 38px; color: var(--ink); border: 0; border-right: 1px solid #cfd8d2; background: white; }
.segmented button:last-child { border-right: 0; }
.segmented button.active { color: white; background: var(--teal); }
.input-row { display: grid; grid-template-columns: 1fr 76px auto; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.input-row input { width: 100%; min-height: 38px; padding: 0 9px; color: var(--ink); border: 1px solid #cfd8d2; border-radius: 4px; background: #fbfcfa; text-align: center; }
.field-help { margin: 8px 0 0; color: #89928e; font-size: 11px; }
.toggle-row { display: grid; grid-template-columns: 1fr 42px; gap: 12px; align-items: center; margin-top: 14px; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row small { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-row i { position: relative; width: 42px; height: 24px; border-radius: 999px; background: #c9cfcc; transition: background .2s; }
.toggle-row i::after { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; content: ""; border-radius: 50%; background: white; box-shadow: 0 2px 6px rgba(0,0,0,.18); transition: transform .2s; }
.toggle-row input:checked + i { background: var(--teal); }
.toggle-row input:checked + i::after { transform: translateX(18px); }
.generate-button { width: 100%; margin-top: auto; }

.result-panel { min-width: 0; padding: 22px; }
.result-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 42px; margin-bottom: 14px; }
.result-toolbar strong, .result-toolbar span { display: block; }
.result-toolbar span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.view-switch { display: flex; border-bottom: 1px solid #d9ddda; }
.view-switch button { padding: 7px 10px; color: var(--muted); border: 0; border-bottom: 2px solid transparent; background: transparent; font-size: 12px; }
.view-switch button.active { color: var(--teal); border-bottom-color: var(--teal); font-weight: 800; }
.canvas-stage { position: relative; display: grid; place-items: center; min-height: 520px; max-height: 680px; overflow: auto; border: 1px solid #dfe3de; background-color: #f1f0eb; background-image: linear-gradient(45deg,#e7e6e1 25%,transparent 25%),linear-gradient(-45deg,#e7e6e1 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#e7e6e1 75%),linear-gradient(-45deg,transparent 75%,#e7e6e1 75%); background-position: 0 0,0 7px,7px -7px,-7px 0; background-size: 14px 14px; }
.canvas-stage canvas { display: none; max-width: calc(100% - 30px); max-height: 640px; margin: 15px; background: white; box-shadow: 0 8px 30px rgba(28, 50, 45, .12); image-rendering: pixelated; }
.empty-result { display: flex; flex-direction: column; align-items: center; color: var(--muted); text-align: center; }
.empty-result strong { margin: 14px 0 5px; color: var(--ink); }
.empty-result small { font-size: 12px; }
.grid-symbol { color: var(--teal); font-size: 58px; line-height: 1; }
.processing { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 15px; background: rgba(247,245,238,.9); }
.processing span { width: 40px; height: 40px; border: 4px solid #bcdad2; border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-summary { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 14px; border: 1px solid #dfe3de; background: white; }
.result-summary div { padding: 13px; border-right: 1px solid #dfe3de; text-align: center; }
.result-summary div:last-child { border-right: 0; }
.result-summary b, .result-summary span { display: block; }
.result-summary b { color: var(--teal-dark); font-size: 17px; }
.result-summary span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.export-row { display: grid; grid-template-columns: .8fr 1.2fr; gap: 12px; margin-top: 12px; }

.palette-section { display: grid; grid-template-columns: .75fr 1.25fr; gap: 72px; align-items: center; max-width: 1240px; margin: 0 auto; padding: 80px 24px; }
.palette-section p:not(.section-kicker) { margin-top: 20px; color: var(--muted); line-height: 1.8; }
.palette-strip { display: grid; grid-template-columns: repeat(11, 1fr); gap: 5px; }
.palette-strip span { aspect-ratio: 1; border: 1px solid rgba(0,0,0,.06); }
footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 24px; padding: 26px 24px; color: #71807b; border-top: 1px solid #dfe3de; background: #eff1eb; font-size: 12px; }
footer strong { color: var(--teal-dark); }

.follow-dialog { width: min(480px, calc(100vw - 28px)); padding: 30px; color: var(--ink); border: 0; border-radius: 8px; background: var(--paper); box-shadow: 0 24px 80px rgba(0,0,0,.24); }
.follow-dialog::backdrop { background: rgba(10,35,34,.58); backdrop-filter: blur(5px); }
.follow-dialog h2 { margin-bottom: 12px; color: var(--ink-strong); font-size: 25px; }
.follow-dialog > p:not(.section-kicker) { color: var(--muted); line-height: 1.7; }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; color: var(--muted); border: 0; background: transparent; font-size: 27px; }
.account-box { display: flex; gap: 12px; align-items: center; margin: 20px 0; padding: 14px; border: 1px solid #dbe5e0; background: #f2f8f5; }
.account-avatar { display: grid; place-items: center; flex: 0 0 48px; height: 48px; color: white; border-radius: 50%; background: var(--teal); font-size: 20px; font-weight: 900; }
.account-box strong, .account-box small { display: block; }
.account-box strong { font-size: 14px; }
.account-box small { margin-top: 5px; color: var(--muted); font-size: 12px; }
.receipt-upload { display: grid; place-items: center; min-height: 90px; margin-bottom: 12px; color: var(--teal); border: 1px dashed #8bbeb2; background: #f7fbf8; font-weight: 800; cursor: pointer; }
.follow-dialog .primary-button { width: 100%; }
.dialog-note { display: block; margin-top: 12px; color: #8c9490; text-align: center; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 28px; max-width: calc(100vw - 32px); padding: 11px 16px; color: white; border-radius: 4px; background: #143f3e; box-shadow: 0 10px 30px rgba(0,0,0,.2); opacity: 0; transform: translate(-50%, 16px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .site-header { min-height: 62px; padding: 8px 16px; }
  .brand small { display: none; }
  .follow-pill { min-height: 34px; padding: 0 11px; font-size: 12px; }
  .intro-band { grid-template-columns: 1fr; gap: 28px; min-height: 0; padding: 40px 16px 32px; }
  h1 { font-size: 42px; }
  .subtitle { font-size: 15px; }
  .feature-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 22px; }
  .feature-row span { padding: 9px 4px; border: 1px solid #dce5df; background: rgba(255,255,255,.55); text-align: center; font-size: 10px; }
  .feature-row b { display: block; font-size: 15px; }
  .sample-wrap { padding: 10px; }
  .sample-badge { right: 17px; bottom: 16px; }
  .workspace { padding: 44px 14px; }
  .workspace-heading { display: block; }
  .workspace-heading h2, .palette-section h2 { font-size: 27px; }
  .privacy-note { margin-top: 12px; }
  .upload-zone { min-height: 280px; padding: 24px 14px; text-align: center; }
  .editor { grid-template-columns: 1fr; }
  .settings-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .generate-button { margin-top: 8px; }
  .result-panel { padding: 12px; }
  .result-toolbar { align-items: start; }
  .view-switch button { padding: 6px; font-size: 10px; }
  .canvas-stage { min-height: 390px; max-height: 70vh; }
  .canvas-stage canvas { max-width: calc(100% - 16px); margin: 8px; }
  .result-summary div { padding: 10px 4px; }
  .export-row { grid-template-columns: 1fr; }
  .export-row .primary-button { grid-row: 1; }
  .palette-section { grid-template-columns: 1fr; gap: 28px; padding: 54px 16px; }
  .palette-strip { grid-template-columns: repeat(11, 1fr); gap: 3px; }
  .follow-dialog { padding: 26px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
