* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: #f4f7fc; color: #0b1a33; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif; }
.signature-header { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; flex-shrink: 0; min-height: 66px; padding: 10px 28px; background: #fff; border-bottom: 1px solid #e7edf5; }
.signature-plan { justify-self: start; display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 8px; font-size: .8rem; font-weight: 500; }
.signature-plan strong { font-size: .85rem; font-style: italic; font-weight: 800; }
.signature-plan.is-free { color: #16803d; background: #eaf8ef; }
.signature-title { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0; font-size: 1.325rem; font-weight: 700; line-height: 1.4; }
.signature-title-icon { display: grid; place-items: center; width: 36px; height: 36px; color: #006acd; font-size: 1.5rem; }
.signature-title-icon > i { display: flex; align-items: center; justify-content: center; line-height: 1; }
.signature-open-link { display: inline-flex; align-items: center; gap: 6px; justify-self: end; color: #69798d; font-size: .9rem; text-decoration: none; white-space: nowrap; }
.signature-open-link:hover { color: #006acd; text-decoration: none; }
.signature-main { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 24px; width: 100%; padding: 32px 24px 16px; }
.signature-wrapper { display: flex; flex: 1 0 auto; align-items: center; justify-content: center; width: 100%; }
.signature-layout { display: grid; grid-template-columns: minmax(0, 350px) minmax(0, 1fr); align-items: start; gap: 24px; width: 100%; max-width: 1200px; }
.signature-card { min-width: 0; padding: 24px 22px; background: #fff; border: 1px solid #e5ebf3; border-radius: 24px; box-shadow: 0 12px 40px rgba(18, 61, 107, .06); }
.section-title { display: flex; align-items: center; gap: 9px; margin: 0 0 18px; font-size: 1rem; font-weight: 650; line-height: 1.5; }
.step { display: inline-grid; flex-shrink: 0; place-items: center; width: 25px; height: 25px; border-radius: 8px; color: #006acd; background: #eef4fe; font-size: .8rem; font-weight: 700; }
.signature-heading { margin-top: 26px; }
.upload-label { display: block; margin-bottom: 9px; color: #315d8d; font-size: .9rem; font-weight: 600; }
input[type="file"] { display: block; width: 100%; min-width: 0; padding: 8px; border: 1px solid #d2dce9; border-radius: 10px; background: #f8faff; color: #4b5a6a; font-size: .8rem; }
input[type="file"]::file-selector-button { padding: 5px 8px; margin-right: 8px; border: 0; border-radius: 6px; background: #eef4fe; color: #006acd; cursor: pointer; }
.help { margin: 9px 0 0; color: #66758a; font-size: .78rem; line-height: 1.7; overflow-wrap: anywhere; }
.file-info { margin: 10px 0 0; color: #315d8d; font-size: .8rem; line-height: 1.6; overflow-wrap: anywhere; }
.ink-settings { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; font-size: .8rem; }
.color-label, .width-label { display: flex; align-items: center; gap: 8px; }
.color-label input { width: 32px; height: 30px; padding: 2px; border: 1px solid #d2dce9; border-radius: 6px; background: #fff; cursor: pointer; }
.width-label { flex: 1; min-width: 110px; }
.width-label input { width: 70px; flex: 1; min-width: 35px; }
input[type="range"] { accent-color: #006acd; cursor: pointer; }
.writing-board { position: relative; overflow: hidden; border: 1px dashed #b9cbe0; border-radius: 14px; background: #f8faff; }
.writing-board::after { content: ''; position: absolute; left: 12%; right: 12%; bottom: 26%; border-bottom: 1px dashed #d2dce9; pointer-events: none; }
#signaturePad { display: block; width: 100%; aspect-ratio: 5 / 2; cursor: crosshair; touch-action: none; }
.writing-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #8895a7; font-size: .85rem; pointer-events: none; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.history-buttons { margin: 14px 0; }
.signature-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 8px 12px; border: 1px solid #e0e7f0; border-radius: 10px; background: #f4f7fc; color: #4b5a6a; font: inherit; font-size: .82rem; font-weight: 500; text-decoration: none; cursor: pointer; line-height: 1.5; }
.signature-btn:hover { background: #eaf0f8; color: #0b1a33; text-decoration: none; }
.signature-btn.primary { color: #fff; background: #006acd; border-color: #006acd; box-shadow: 0 4px 14px rgba(0, 106, 205, .12); }
.signature-btn.primary:hover { color: #fff; background: #0059b3; }
.signature-btn.danger { color: #b63d48; background: #fff7f8; }
.signature-btn.small { min-height: 32px; padding: 5px 9px; font-size: .75rem; white-space: nowrap; }
.signature-btn:disabled, fieldset:disabled .signature-btn { opacity: .45; cursor: not-allowed; box-shadow: none; }
.full-width { width: 100%; }
.preview-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.preview-heading .section-title { margin: 0; }
.preview-area { display: flex; align-items: center; justify-content: center; min-height: 280px; padding: 16px; overflow: hidden; border: 1px solid #e5ebf3; border-radius: 18px; background-color: #f8faff; background-image: conic-gradient(#eaf0f7 25%, transparent 0 50%, #eaf0f7 0 75%, transparent 0); background-size: 20px 20px; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; color: #66758a; }
.empty-state > i { color: #9cb7d6; font-size: 2.6rem; }
.empty-state strong { color: #315d8d; font-size: 1rem; font-weight: 600; }
.empty-state p { margin: 0; font-size: .82rem; line-height: 1.7; }
.preview-surface { width: 100%; }
#imagePreview { display: block; width: 100%; height: auto; touch-action: pan-y; }
#imagePreview.has-signature { cursor: grab; touch-action: none; }
#imagePreview.is-dragging { cursor: grabbing; }
.placement-settings { min-width: 0; margin: 18px 0; padding: 16px; border: 1px solid #eef2f8; border-radius: 14px; background: #f8faff; }
.placement-settings:disabled { opacity: .55; }
.placement-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 12px; }
.placement-grid label { color: #4b5a6a; font-size: .8rem; }
.placement-grid output { float: right; color: #006acd; font-variant-numeric: tabular-nums; }
.placement-grid input { display: block; width: 100%; margin-top: 10px; }
.export-row { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
.export-row label { display: flex; flex-direction: column; gap: 8px; color: #4b5a6a; font-size: .8rem; }
select { max-width: 100%; min-height: 38px; padding: 7px 28px 7px 10px; border: 1px solid #d2dce9; border-radius: 10px; background: #fff; color: #0b1a33; font: inherit; }
.signature-status { min-height: 22px; margin: 14px 0 0; color: #16803d; font-size: .82rem; line-height: 1.7; overflow-wrap: anywhere; }
.signature-status.is-error { color: #c43d4b; }
.export-result { display: flex; align-items: center; gap: 16px; margin-top: 12px; padding: 16px; border: 1px solid #d8ebdf; border-radius: 14px; background: #f4fbf6; }
.export-result > img { display: block; width: 100px; height: 100px; flex-shrink: 0; object-fit: contain; border-radius: 8px; background: #fff; }
.export-result > div { min-width: 0; }
.export-result strong { font-size: .9rem; }
.export-result .signature-btn { margin-top: 10px; }
.signature-tips { flex-shrink: 0; width: 100%; max-width: 1200px; margin-top: auto; padding: 18px 16px 0; border-top: 1px solid #eef2f8; color: #66758a; font-size: .9rem; line-height: 1.8; text-align: center; }
.signature-tips p { margin: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible { outline: 3px solid #8ec7ff; outline-offset: 3px; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
@media (max-width: 991.98px) {
    .signature-layout { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 16px; }
    .signature-card { padding: 20px 16px; }
}
@media (max-width: 767.98px) {
    .signature-header { padding: 8px 16px; gap: 10px; }
    .signature-plan { padding: 5px 8px; font-size: .72rem; }
    .signature-title { gap: 7px; font-size: 1.175rem; }
    .signature-title-icon { width: 32px; height: 32px; font-size: 1.3rem; }
    .signature-open-link { font-size: .8rem; }
    .signature-main { padding: 24px 16px 16px; gap: 20px; }
    .signature-layout { grid-template-columns: minmax(0, 1fr); max-width: 620px; }
    .signature-card { padding: 18px 16px 22px; border-radius: 22px; }
    .preview-area { min-height: 240px; padding: 10px; }
}
@media (max-width: 575.98px) {
    .signature-header { grid-template-columns: minmax(0, 1fr) auto; }
    .signature-title { grid-column: 1 / -1; grid-row: 1; }
    .signature-plan { grid-column: 1; grid-row: 2; }
    .signature-open-link { grid-column: 2; grid-row: 2; }
    .signature-tips { padding: 18px 12px 0; font-size: .8rem; }
    .placement-grid { gap: 14px; }
    .export-result { flex-direction: column; align-items: start; }
    .export-result > img { width: 100%; height: 140px; }
    .export-row > label, .export-row > button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
