:root {
    color-scheme: light;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: #172948;
    background: #f5f7fd;
    --blue: #284de0;
    --ink: #172948;
    --muted: #52637f;
    --line: #dce4f2;
}
* { box-sizing: border-box; }
body { margin: 0; }
body.embedded { display: flow-root; }
.embedded .masthead { display: none; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
:focus-visible { outline: 3px solid #5270f5; outline-offset: 3px; }
[hidden] { display: none !important; }
.frame { width: min(1160px, calc(100% - 40px)); margin-inline: auto; }
.masthead { background: #fff; border-bottom: 1px solid var(--line); }
.masthead-inner { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-size: 19px; font-weight: 750; letter-spacing: -.03em; }
.privacy { color: #244678; background: #edf3ff; font-size: 13px; font-weight: 650; padding: 7px 11px; border-radius: 8px; }
h1 { margin: 34px 0 6px; font-size: clamp(31px, 5vw, 48px); line-height: 1.1; letter-spacing: -.045em; }
.intro { margin: 0 0 24px; color: var(--muted); line-height: 1.55; }
.workspace { display: grid; grid-template-columns: 280px minmax(0, 1fr); align-items: start; gap: 16px; margin-bottom: 24px; }
.controls, .viewer { background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.controls { padding: 0 18px; }
.controls section { padding: 17px 0; }
.controls section + section { border-top: 1px solid var(--line); }
.controls h2 { margin: 0 0 9px; font-size: 15px; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.action { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; padding: 8px 12px; color: #203d92; background: #eff3ff; border: 1px solid #d7e1fc; border-radius: 9px; font-weight: 680; line-height: 1.3; }
.action:hover:not(:disabled) { background: #e2eaff; }
.primary { color: white; background: var(--blue); border-color: var(--blue); }
.primary:hover:not(:disabled) { background: #1d3ab8; }
.size-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 16px; font-size: 13px; }
.size-row output { font-variant-numeric: tabular-nums; color: var(--muted); }
#stamp-size { width: 100%; min-height: 31px; margin: 2px 0; accent-color: var(--blue); }
.stamp-center { margin-top: 8px; }
.stamp-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.stamp-actions button {
    min-height: 42px;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #24395e;
    background: #f7f9ff;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.25;
}
.stamp-actions button:hover:not(:disabled) { background: #e9efff; }
.stamp-actions .danger { color: #a1253d; border-color: #efd4da; background: #fff7f8; }
.stamp-actions .danger:hover:not(:disabled) { background: #ffebee; }
.viewer-bar { padding: 9px 15px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.viewer-label { font-size: 14px; font-weight: 700; }
.pages { display: flex; align-items: center; gap: 8px; }
.pages select { min-width: 0; max-width: min(32vw, 220px); }
.pages select, .field input { min-height: 40px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); font: inherit; }
.field { display: grid; gap: 4px; margin-top: 10px; font-size: .84rem; }
.field input { width: 100%; }
.pages button { width: 41px; height: 40px; padding: 0; color: var(--ink); border: 1px solid var(--line); background: #f7f9ff; border-radius: 8px; font-size: 24px; line-height: 1; }
[dir="rtl"] .pages button { transform: scaleX(-1); }
[dir="rtl"] .sheet { direction: ltr; }
.pages output { min-width: 52px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.status { margin: 0; padding: 8px 15px; background: #eef3ff; font-size: 13px; }
.status:empty { display: none; }
.status[data-error="true"] { color: #912739; background: #fff0f2; }
.preview-area { display: grid; justify-items: center; align-items: start; min-height: 440px; padding: 18px; background: #e9eef9; border-block: 1px solid var(--line); }
.empty { display: grid; justify-items: center; align-self: center; text-align: center; max-width: 420px; padding: 24px 12px; }
.empty h2 { margin: 0; font-size: 21px; }
.empty p { margin: 9px 0 17px; color: var(--muted); line-height: 1.5; }
.empty .action { width: auto; padding-inline: 18px; }
.sheet { position: relative; width: 100%; max-width: 700px; background: #fff; box-shadow: 0 3px 17px #24386225; isolation: isolate; }
.sheet canvas { display: block; width: 100%; height: auto; }
.word-page { display: block; position: relative; width: 100%; overflow: hidden; pointer-events: none; }
.word-measure { position: absolute; inset: 0 auto auto -20000px; visibility: hidden; pointer-events: none; }
.placements { position: absolute; inset: 0; }
.placements.sheet-region { clip-path: inset(0); }
.placements[data-ready="true"] { cursor: crosshair; }
.word-page:not([hidden]) + .placements { pointer-events: none; }
.sheet:has(.word-page:not([hidden]) + .placements[data-ready="true"]) { cursor: crosshair; }
.placed { position: absolute; padding: 0; border: 0; background: transparent; touch-action: none; cursor: grab; pointer-events: auto; }
.placed:active { cursor: grabbing; }
.placed:focus-visible { outline: 2px dashed #586681; outline-offset: 2px; }
.placed img {
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--stamp-image-width, 100%);
    height: var(--stamp-image-height, 100%);
    display: block;
    transform: translate(-50%, -50%) rotate(var(--stamp-angle, 0deg));
    pointer-events: none;
}
.viewer-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 15px; font-size: 13px; color: var(--muted); }
.viewer-footer > span { flex: 1 1 24rem; line-height: 1.45; }
.footer-pages { margin-inline-start: auto; }
.footer-pages button:hover:not(:disabled) { background: #e9efff; }
.word-review { border-top: 1px solid var(--line); padding: 10px 15px; color: var(--muted); font-size: 13px; }
.word-review summary { cursor: pointer; font-weight: 600; }
.word-review ul { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.word-review li { border-inline-start: 3px solid #496ac2; padding: 4px 8px; overflow-wrap: anywhere; }
.word-review li[data-kind="inserted"] { border-color: #217856; }
.word-review li[data-kind="deleted"] { border-color: #a02b3c; }
.word-review li > div { margin-top: 3px; white-space: pre-wrap; }
@media (max-width: 680px) {
    .frame { width: calc(100% - 24px); }
    .workspace { grid-template-columns: 1fr; gap: 12px; }
    .masthead-inner { min-height: 56px; }
    .brand { font-size: 16px; }
    .privacy { font-size: 11px; }
    h1 { margin-top: 23px; }
    .intro { margin-bottom: 17px; }
    .controls { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; padding-inline: 12px; }
    .controls section { min-width: 0; padding-block: 12px; }
    .controls section:nth-child(2) { border-top: 0; }
    .controls .export { grid-column: 1 / -1; }
    .preview-area { min-height: 280px; padding: 9px; }
}
