@font-face { font-family: Baskervville; src: url("assets/baskervville.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: Inter; src: url("assets/inter.ttf") format("truetype"); font-display: swap; }
:root {
  --paper: #f7f4ef;
  --panel: #fcfaf7;
  --ink: #302d2a;
  --muted: #655c51;
  --line: #d5cbbf;
  --sand: #eae1d5;
  color: var(--ink);
  background: var(--paper);
  font: 14px/1.5 Inter, Arial, sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
img { max-width: 100%; display: block; }
button, textarea, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button, select, textarea { border: 1px solid var(--line); border-radius: 2px; background: var(--panel); }
button { min-height: 43px; padding: 8px 15px; }
button:hover { border-color: #8e7a64; }
:focus-visible { outline: 2px solid #765634; outline-offset: 3px; }
p, h1, h2 { margin: 0; }
h1, h2, legend { font-family: Baskervville, Georgia, serif; font-weight: 400; line-height: 1.1; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.skip:focus { position: absolute; z-index: 10; background: white; padding: 12px; }
.masthead {
  position: relative;
  display: grid;
  place-items: center;
  height: 76px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.masthead img { width: 210px; height: 70px; object-fit: contain; }
.masthead span { position: absolute; right: max(24px, calc((100vw - 1280px) / 2)); color: var(--muted); font-size: 12px; }
main { max-width: 1330px; margin: auto; padding: 42px 28px 20px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.intro h1 { font-size: clamp(45px, 5vw, 70px); letter-spacing: -.05em; }
.intro p { color: var(--muted); margin-top: 8px; }
.layout-picker, .flow-tabs, .direct-tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.layout-picker { border: 1px solid var(--line); background: #eee8e0; padding: 4px; border-radius: 3px; }
.layout-picker button, .flow-tabs button, .direct-tabs button { background: transparent; border-color: transparent; }
.layout-picker button[aria-pressed="true"], .direct-tabs button[aria-pressed="true"] { background: var(--ink); color: #fffaf4; }
.editor { display: grid; grid-template-columns: minmax(0, 1.28fr) minmax(340px, 1fr); gap: 24px; align-items: start; }
.preview { background: radial-gradient(ellipse at 50% 45%, #f8f0e4, #eee3d4 70%, #e8dbca); border: 1px solid #ddcfbe; min-width: 0; }
body[data-layout="studio"] .preview { position: sticky; top: 12px; }
.preview-head { padding: 25px 26px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.preview h2 { font-size: 28px; letter-spacing: -.02em; }
.preview-head p, .drag-hint { color: var(--muted); font-size: 12px; }
.preview-head p { margin-top: 6px; }
#guide-toggle { background: #fffcf590; min-height: 40px; font-size: 12px; white-space: nowrap; }
#guide-toggle[aria-pressed="true"] { border-color: #8f7c68; }
.stage-wrap { display: grid; place-items: center; padding-inline: 12px; }
.stage { position: relative; width: min(100%, 465px); aspect-ratio: 1; isolation: isolate; }
.stage img, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage img { pointer-events: none; filter: drop-shadow(0 18px 13px #5e472f37); }
.stage[data-metal="silver"] img { filter: grayscale(1) brightness(1.02) contrast(1.08) drop-shadow(0 18px 13px #48474638); }
.stage canvas { display: block; touch-action: pan-y; }
.stage canvas.drag-enabled { touch-action: none; cursor: grab; }
.stage canvas.dragging { cursor: grabbing; }
.drag-hint { padding: 0 20px 20px; text-align: center; }
.tools { background: var(--panel); border: 1px solid var(--line); padding: 25px 28px; min-width: 0; }
fieldset { padding: 0 0 18px; margin: 0 0 18px; border: 0; border-bottom: 1px solid var(--line); min-width: 0; }
fieldset:last-of-type { border-bottom: 0; padding-bottom: 0; margin-bottom: 0; }
legend { font-size: 25px; padding: 0; margin: 0 0 12px; letter-spacing: -.02em; }
.metal-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.metal-buttons button { display: flex; align-items: center; gap: 8px; }
.metal-buttons button[aria-pressed="true"] { background: #f1e9dd; border-color: #8f7c68; }
.swatch { width: 17px; height: 17px; flex: none; border-radius: 50%; border: 1px solid #6b5d4b55; }
.gold { background: linear-gradient(135deg, #e9d4a1, #b58b48); }
.silver { background: linear-gradient(135deg, #f3f2f0, #aaa9a7); }
textarea { display: block; resize: vertical; width: 100%; min-height: 59px; padding: 10px 12px; margin-top: 5px; }
.field-label, .text-options label, #image-size-wrap { font-size: 13px; }
.input-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; margin-bottom: 12px; }
.text-options { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; align-items: start; }
.text-options label { min-width: 0; }
select { min-height: 41px; padding: 6px 10px; }
.text-options select { display: block; margin-top: 4px; width: 100%; }
input[type="range"] { display: block; width: 100%; height: 39px; margin: 0; accent-color: #795c3f; }
.file-row { display: flex; gap: 10px; flex-wrap: wrap; }
.file-row #upload { border-style: dashed; background: #f2ece3; }
.field-help, .error { margin-top: 7px; font-size: 12px; overflow-wrap: anywhere; }
.field-help { color: var(--muted); }
.error { color: #8e2116; }
#image-size-wrap { display: block; margin-top: 12px; }
output { color: var(--muted); margin-left: 6px; }
.position-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.arrows { display: flex; gap: 3px; }
.arrows button { min-width: 39px; padding-inline: 7px; font-size: 17px; }
.quiet { background: transparent; border-color: transparent; text-decoration: underline; text-underline-offset: 4px; }
.primary { background: var(--ink); color: #fffaf4; border-color: var(--ink); }
.editor-footer { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-top: 16px; padding-top: 9px; border-top: 1px solid var(--line); }
.editor-footer p { color: var(--muted); font-size: 12px; max-width: 59ch; }
.editor-footer button { flex-shrink: 0; }
.flow { margin-bottom: 23px; }
.flow-tabs { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.flow-tabs button[aria-current="step"] { border-color: #99846b; background: #f0e7d9; }
.flow-actions { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; display: flex; justify-content: space-between; gap: 5px; }
.flow-actions #next { margin-left: auto; }
body[data-layout="guided"] .editor { grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr); gap: 0; border: 1px solid var(--line); align-items: stretch; background: var(--panel); }
body[data-layout="guided"] .tools, body[data-layout="guided"] .preview { border: 0; padding: 32px; }
body[data-layout="guided"] .preview { padding: 0; }
body[data-layout="guided"] .preview, body[data-layout="direct"] .preview { background: radial-gradient(ellipse at 50% 42%, #f8f4ee, #e8dccd); }
body[data-layout="guided"] .stage { width: min(100%, 510px); }
body[data-layout="direct"] .editor { grid-template-columns: 1fr; gap: 0; max-width: 780px; margin-inline: auto; border: 1px solid var(--line); }
body[data-layout="direct"] .preview, body[data-layout="direct"] .tools { border: 0; }
body[data-layout="direct"] .stage { width: min(100%, 330px); }
body[data-layout="direct"] .tools { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 0 24px; padding-block: 15px; border-top: 1px solid var(--line); }
body[data-layout="direct"] .tools fieldset { border: 0; padding-bottom: 0; margin-bottom: 0; }
body[data-layout="direct"] #metal-tool { grid-column: 1; grid-row: 1 / 3; border-right: 1px solid var(--line); padding-right: 16px; }
body[data-layout="direct"] .metal-buttons { grid-template-columns: 1fr; }
body[data-layout="direct"] .direct-tabs { grid-column: 2; margin-bottom: 10px; }
body[data-layout="direct"] :is(#text-tool, #image-tool, #position-tool) { grid-column: 2; }
body[data-layout="direct"] :is(#text-tool, #image-tool) legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
body[data-layout="direct"] #position-tool { margin-top: 12px; }
@media (max-width: 750px) {
  main { padding: 26px 16px 16px; }
  .intro { align-items: flex-start; flex-direction: column; gap: 15px; margin-bottom: 15px; }
  .intro p { font-size: 13px; }
  .layout-picker { width: 100%; }
  .layout-picker button { flex: 1; min-height: 44px; padding-inline: 7px; font-size: 12px; }
  .editor, body[data-layout="guided"] .editor { grid-template-columns: minmax(0,1fr); gap: 10px; }
  body[data-layout="guided"] .editor, body[data-layout="direct"] .editor { gap: 0; }
  .masthead { height: 57px; }
  .masthead img { width: 150px; height: 50px; }
  .masthead span { right: 12px; font-size: 9px; }
  .preview-head { padding: 14px 14px 0; }
  .preview h2 { font-size: 23px; }
  body[data-layout="studio"] .preview { position: static; }
  .stage, body[data-layout="guided"] .stage, body[data-layout="direct"] .stage { width: min(100%, 285px); }
  .drag-hint { padding: 0 12px 10px; font-size: 11px; }
  .tools, body[data-layout="guided"] .tools { padding: 17px; }
  body[data-layout="direct"] .tools { grid-template-columns: minmax(0,1fr); }
  body[data-layout="direct"] #metal-tool { grid-column: 1; grid-row: auto; border: 0; padding-right: 0; margin-bottom: 9px; }
  body[data-layout="direct"] #metal-tool legend { font-size: 19px; margin-bottom: 7px; }
  body[data-layout="direct"] .metal-buttons { grid-template-columns: 1fr 1fr; }
  body[data-layout="direct"] :is(.direct-tabs, #text-tool, #image-tool, #position-tool) { grid-column: 1; }
  .editor-footer { align-items: flex-start; flex-direction: column; gap: 4px; }
  .editor-footer button { padding-left: 0; }
  textarea, select { font-size: 16px; }
}
@media (max-width: 750px) and (min-height: 650px) {
  body[data-layout="direct"] .preview { position: sticky; top: 0; z-index: 1; border-bottom: 1px solid var(--line); }
  body[data-layout="direct"] .stage { width: min(100%, 215px); }
}
@media (max-width: 365px) {
  .masthead span { display: none; }
  .position-tools .arrows { order: 3; width: 100%; }
  .layout-picker button { font-size: 11px; }
}

/* Shop integration shares the existing editor without another masthead. */
body[data-shop-embedded] .masthead,
body[data-shop-embedded] .intro,
body[data-shop-embedded] > .skip { display: none; }
body[data-shop-embedded] main { max-width: none; padding: 0; }
body[data-shop-embedded] .preview { position: static; }
body[data-shop-embedded] .editor { gap: 20px; }
body[data-shop-embedded] { background: #f7f4ef; }
body[data-shop-embedded] .save-engraving { display: block; width: 100%; margin-top: 24px; min-height: 48px; }
body[data-shop-embedded] .save-engraving:disabled { opacity: .6; cursor: wait; }
body[data-shop-embedded] #save-message { font-size: 14px; }
body[data-shop-embedded] .field-label,
body[data-shop-embedded] .text-options label,
body[data-shop-embedded] #image-size-wrap { font-size: 14px; }
body[data-shop-embedded] .input-meta { font-size: 12px; }
@media (max-width: 750px) {
  body[data-shop-embedded] .editor { gap: 12px; }
}
