:root { color-scheme: light; --ink: #292621; --muted: #69645c; --line: #e4ded5; --accent: #a84b31; --panel: #f5f2ed; }
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #fff; font: 16px/1.45 system-ui, sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
button:focus-visible, input:focus-visible, .front-artwork:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.cover-page { max-width: 1200px; margin: auto; padding: 28px clamp(16px, 4vw, 60px) 56px; }
.cover-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 26px; }
.eyebrow { color: var(--accent); font-size: 12px; letter-spacing: .18em; font-weight: 700; margin: 0 0 6px; }
h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.1; margin: 0; }
h2 { font-size: 17px; margin: 0 0 15px; }
.cover-workspace { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(290px, .8fr); gap: 24px; align-items: start; }
.cover-preview-panel { background: var(--panel); border-radius: 16px; padding: 26px; display: grid; place-items: center; min-height: 620px; }
/* The printed cover is one rectangle. Only its background layer is recolored. */
.cover-preview { --cover-aspect: 58 / 112; --stamp-width: 67.24%; --stamp-height: 13.39%; --face-height: 43.3%; --image-size: 75%; --image-x: 50%; --image-y: 50%; position: relative; width: min(100%, 310px); aspect-ratio: var(--cover-aspect); overflow: hidden; background: white; box-shadow: 0 14px 36px #33291f30; isolation: isolate; }
.cover-background { position: absolute; inset: 0; background: #d9c4a1 url('/assets/images/cover_bg.png') center / 100% 100% no-repeat; filter: var(--cover-filter, none); }
.cover-preview[data-background="solid"] .cover-background { background: var(--solid-color, #888); filter: none; }
.cover-back, .cover-front { position: absolute; left: 0; right: 0; height: var(--face-height); display: grid; place-items: center; }
.cover-back { top: 0; }
.cover-front { bottom: 0; }
.stamp-area { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: var(--stamp-width); height: var(--stamp-height); background: #fff; }
.back-logo { width: 60%; max-height: 70%; object-fit: contain; transform: rotate(180deg); }
.front-artwork { position: absolute; left: var(--image-x); top: var(--image-y); width: var(--image-size); max-height: 85%; object-fit: contain; transform: translate(-50%, -50%); cursor: grab; touch-action: none; user-select: none; -webkit-user-drag: none; }
.front-artwork:active { cursor: grabbing; }
.cover-controls { border: 1px solid var(--line); border-radius: 14px; padding: 22px; min-width: 0; }
.control-group + .control-group { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 22px; }
.button { border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 8px; padding: 9px 14px; }
.button:not(:disabled):hover { border-color: var(--accent); }
.button-primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; }
.button-row { display: flex; gap: 12px; margin-bottom: 14px; }
.background-choice { display: grid; gap: 6px; flex: 1; padding: 6px 6px 8px; background: white; border: 2px solid var(--line); border-radius: 10px; color: var(--ink); font-size: 13px; text-align: center; }
.background-choice:hover, .background-choice.is-active { border-color: var(--accent); }
.background-sample { display: block; height: 58px; border-radius: 5px; }
.pattern-sample { background: #d9c4a1 url('/assets/images/cover_bg.png') center / cover; }
.solid-sample { background: var(--solid-color, #888); }
label { display: grid; gap: 5px; color: var(--muted); font-size: 13px; margin: 12px 0; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] { width: 100%; height: 42px; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: white; }
.image-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.image-choice { border: 2px solid var(--line); padding: 5px; background: white; border-radius: 8px; cursor: pointer; aspect-ratio: 1; min-width: 0; }
.image-choice:hover, .image-choice.is-active { border-color: var(--accent); }
.image-choice img { width: 100%; height: 100%; object-fit: contain; display: block; }
.empty-state { color: var(--muted); font-size: 14px; grid-column: 1 / -1; }
.pager { display: flex; justify-content: center; align-items: center; gap: 15px; margin: 12px 0; color: var(--muted); font-size: 13px; }
.pager .button { padding: 3px 12px; font-size: 22px; line-height: 1.2; }
.image-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-top: 12px; }
.image-actions label { flex: 1; min-width: 150px; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 800px) { .cover-workspace { grid-template-columns: 1fr; } .cover-preview-panel { min-height: 0; } }
@media (max-width: 420px) { .cover-page { padding: 18px 12px 36px; } .cover-header { align-items: start; } .cover-preview-panel { padding: 20px; } .cover-controls { padding: 16px; } }
@page { size: A4; margin: 0; }
@media print {
    body { margin: 0; background: white; }
    .cover-page, .cover-workspace, .cover-preview-panel { display: block; max-width: none; margin: 0; padding: 0; background: white; min-height: 0; }
    .cover-header, .cover-controls { display: none; }
    .cover-preview { width: var(--cover-width); height: var(--cover-height); aspect-ratio: auto; margin: 0 auto; box-shadow: none; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    .cover-background, .stamp-area { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
