:root {
  --ink: #17232d;
  --muted: #5f6c76;
  --paper: #f6f2e9;
  --surface: #ffffff;
  --line: #d9d5cc;
  --brand: #1c3447;
  --brand-2: #2d5873;
  --accent: #c89b48;
  --danger: #a53a3a;
  --shadow: 0 18px 60px rgba(23, 35, 45, 0.12);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
button, input { font: inherit; }
button { touch-action: manipulation; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 64px);
  background: var(--brand);
  color: white;
  border-bottom: 4px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand img { flex: none; }
.brand h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.35rem, 2.6vw, 2rem); font-weight: 600; }
.eyebrow { margin: 0 0 2px; color: #d9e4eb; font-size: .69rem; font-weight: 800; letter-spacing: .13em; }
.privacy-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 13px; border: 1px solid rgba(255,255,255,.24); border-radius: 999px; color: #e6f2ed; font-size: .86rem; white-space: nowrap; }
.privacy-pill span { color: #6fd59c; font-size: .8rem; }

main { width: min(1500px, 100%); margin: 0 auto; padding: clamp(24px, 4vw, 54px); }
.intro-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
  min-height: 510px;
}
.intro-copy h2, .stage h2, .privacy-note h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; }
.intro-copy h2 { margin: 0 0 18px; max-width: 750px; font-size: clamp(2.2rem, 5vw, 4.5rem); line-height: 1.02; letter-spacing: -.025em; }
.intro-copy > p { max-width: 760px; color: var(--muted); font-size: clamp(1rem, 1.7vw, 1.22rem); }
.feature-list { display: grid; gap: 9px; padding: 0; margin: 28px 0 0; list-style: none; }
.feature-list li { position: relative; padding-left: 28px; }
.feature-list li::before { content: "✓"; position: absolute; left: 0; color: var(--brand-2); font-weight: 900; }

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 330px;
  padding: 38px;
  text-align: center;
  background: rgba(255,255,255,.7);
  border: 2px dashed #9ca8af;
  border-radius: 26px;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.dragging { transform: translateY(-3px); border-color: var(--brand-2); background: white; outline: none; box-shadow: var(--shadow); }
.upload-icon { display: grid; place-items: center; width: 76px; height: 76px; margin-bottom: 18px; border-radius: 50%; background: var(--brand); color: white; font-size: 2.4rem; font-weight: 200; }
.drop-zone strong { font-size: 1.25rem; }
.drop-zone span { color: var(--muted); }
.drop-zone small { margin-top: 14px; color: var(--muted); }

.workspace { display: grid; gap: 22px; }
.stepper { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; color: var(--muted); border-radius: 999px; font-size: .9rem; font-weight: 700; }
.step b { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid currentColor; border-radius: 50%; }
.step.active { background: var(--brand); color: white; }
.step.complete { color: var(--brand-2); }

.stage { padding: clamp(20px, 3vw, 38px); background: rgba(255,255,255,.72); border: 1px solid rgba(28,52,71,.11); border-radius: 24px; box-shadow: var(--shadow); }
.stage-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; margin-bottom: 24px; }
.stage-heading h2 { margin: 2px 0 7px; font-size: clamp(1.7rem, 3vw, 2.55rem); line-height: 1.1; }
.stage-heading p:not(.stage-kicker) { max-width: 850px; margin: 0; color: var(--muted); }
.stage-kicker { margin: 0; color: var(--brand-2); font-size: .76rem; font-weight: 900; letter-spacing: .12em; }
.editor-layout, .result-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 24px; align-items: start; }
.canvas-shell, .result-shell { position: relative; display: grid; place-items: center; min-width: 0; min-height: 420px; overflow: hidden; background: #20262b; border-radius: 15px; }
#editorCanvas { display: block; max-width: 100%; touch-action: none; cursor: crosshair; }
.busy-overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: rgba(14, 24, 31, .78); color: white; z-index: 5; }
.spinner { width: 42px; height: 42px; border: 4px solid rgba(255,255,255,.28); border-top-color: white; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.controls-card { display: grid; gap: 21px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; position: sticky; top: 18px; }
.control-group { display: grid; gap: 8px; }
.control-group label { font-weight: 800; }
.control-group small { color: var(--muted); line-height: 1.35; }
.range-row { display: grid; grid-template-columns: 1fr 54px; gap: 12px; align-items: center; }
.range-row input { width: 100%; accent-color: var(--brand-2); }
.range-row output { text-align: right; color: var(--brand); font-variant-numeric: tabular-nums; font-weight: 800; }
.button-stack { display: grid; gap: 9px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-weight: 800; transition: transform .14s ease, background .14s ease, border-color .14s ease; }
.button:hover { transform: translateY(-1px); }
.button:focus-visible { outline: 3px solid rgba(45,88,115,.28); outline-offset: 2px; }
.button.primary { background: var(--brand); color: white; }
.button.primary:hover { background: #122b3d; }
.button.secondary { background: #e5edf1; color: var(--brand); border-color: #bfd0da; }
.button.ghost { background: transparent; color: var(--brand); border-color: #bac4ca; }
.button.wide { width: 100%; }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.selected-corner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; background: #f3f5f6; border-radius: 9px; font-size: .86rem; }
.selected-corner strong { color: var(--brand-2); }

.result-shell { min-height: 440px; padding: 18px; }
.result-shell canvas, .export-preview canvas { display: block; max-width: 100%; max-height: 72vh; width: auto; height: auto; box-shadow: 0 12px 34px rgba(0,0,0,.3); }
.checkerboard { background-color: #c8c8c8; background-image: linear-gradient(45deg,#aaa 25%,transparent 25%),linear-gradient(-45deg,#aaa 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#aaa 75%),linear-gradient(-45deg,transparent 75%,#aaa 75%); background-size: 28px 28px; background-position: 0 0,0 14px,14px -14px,-14px 0; }
.rotation-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.check-row { display: flex; align-items: flex-start; gap: 10px; color: var(--ink); cursor: pointer; }
.check-row input { margin-top: 4px; accent-color: var(--brand-2); }
.info-box { padding: 12px; border-left: 4px solid var(--accent); background: #f7f3e9; color: var(--muted); font-size: .88rem; }

.export-card { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 26px; }
.export-preview { display: grid; place-items: center; min-height: 450px; padding: 22px; overflow: hidden; border-radius: 15px; }
.export-options { display: grid; align-content: start; gap: 22px; padding: 23px; background: white; border: 1px solid var(--line); border-radius: 15px; }
.text-input { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #aeb9bf; border-radius: 8px; }
.text-input:focus { outline: 3px solid rgba(45,88,115,.2); border-color: var(--brand-2); }
.download-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.privacy-note { margin-top: 46px; padding: 26px 30px; border-top: 1px solid #c9c4ba; color: var(--muted); }
.privacy-note h2 { margin: 0 0 8px; color: var(--ink); font-size: 1.3rem; }
.privacy-note p { margin: 0; max-width: 1100px; }
footer { display: flex; justify-content: space-between; gap: 20px; padding: 22px clamp(18px, 4vw, 64px); background: #e8e2d7; color: var(--muted); font-size: .84rem; }
.toast { position: fixed; left: 50%; bottom: 26px; z-index: 20; transform: translateX(-50%); max-width: min(92vw, 620px); padding: 12px 18px; background: #122b3d; color: white; border-radius: 9px; box-shadow: var(--shadow); text-align: center; }

@media (max-width: 950px) {
  .intro-panel, .editor-layout, .result-layout, .export-card { grid-template-columns: 1fr; }
  .intro-panel { min-height: 0; }
  .controls-card { position: static; }
  .canvas-shell { min-height: 300px; }
  .stage-heading { flex-direction: column; }
}
@media (max-width: 620px) {
  .site-header { align-items: flex-start; }
  .privacy-pill { display: none; }
  main { padding: 18px 12px 34px; }
  .intro-copy h2 { font-size: 2.5rem; }
  .drop-zone { min-height: 270px; padding: 26px 18px; }
  .stage { padding: 17px 12px; border-radius: 15px; }
  .download-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
