:root{font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#1d1d1f;background:#ece9e1;color-scheme:light;--paper:#fff;--ink:#1d1d1f;--muted:#74716a;--line:#dedbd2;--warm:#f4f2ec;--danger:#ad3028}
*{box-sizing:border-box}html,body{margin:0;height:100%;background:radial-gradient(circle at 50% -20%,#fff 0,#f1efe9 35%,#e8e5dd 100%)}body{min-height:100dvh;overflow:hidden}.app-shell{width:min(760px,100%);height:100dvh;margin:0 auto;padding:max(10px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));display:flex;flex-direction:column;gap:8px}.topbar{height:44px;flex:0 0 44px;display:flex;align-items:center;justify-content:space-between;padding:0 2px}.brand-wrap{display:flex;align-items:center;gap:9px}.mark{width:34px;height:34px;border-radius:11px;display:block;object-fit:cover;box-shadow:0 5px 16px #0002}.brand{font-weight:850;font-size:16px;letter-spacing:-.025em}.icon-btn{border:1px solid #d8d5cd;background:#ffffffc9;color:#333;width:32px;height:32px;border-radius:50%;font-weight:800;font-size:15px;cursor:pointer}.document-card{background:var(--paper);border:1px solid #dedbd2;border-radius:22px;padding:12px;box-shadow:0 16px 48px #3c393112;flex:1;min-height:0;display:flex;flex-direction:column}.doc-name{width:100%;flex:0 0 auto;border:0;border-bottom:1px solid #e1ddd4;padding:4px 2px 9px;font:750 17px/1.15 inherit;color:#222;background:transparent;outline:none}.doc-name:focus{border-color:#222}.workspace{flex:1;min-height:0;overflow:hidden;display:flex}.empty-state{margin:auto;text-align:center;padding:12px 8px}.empty-visual{width:64px;height:64px;background:#f4f2ec;border-radius:20px;display:grid;place-items:center;margin:0 auto 12px}.empty-visual svg{width:39px;fill:none;stroke:#77736a;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}.empty-state h1{font-size:18px;letter-spacing:-.025em;margin:0 0 4px}.empty-state p{margin:0;color:#77736a;font-size:12px}.pages-section{width:100%;height:100%;min-height:0;display:flex;flex-direction:column}.section-heading{display:flex;justify-content:space-between;align-items:center;padding:10px 2px 7px;font-size:11px;font-weight:800;flex:0 0 auto}.text-btn{border:0;background:transparent;font:700 10px inherit;cursor:pointer;padding:4px}.text-btn.danger{color:var(--danger)}.pages-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;overflow:auto;min-height:0;padding:0 1px 3px;overscroll-behavior:contain}.page-card{position:relative;border:1px solid #dedbd2;border-radius:13px;background:#f7f5f0;padding:6px;min-width:0}.page-thumb{width:100%;aspect-ratio:3/4;object-fit:contain;background:#e8e5df;border-radius:9px;display:block}.page-number{position:absolute;top:10px;left:10px;background:#1d1d1fdd;color:#fff;border-radius:999px;padding:2px 6px;font-size:8px;font-weight:800}.page-tools{display:grid;grid-template-columns:repeat(3,1fr);gap:3px;margin-top:5px}.page-tools button{border:1px solid #ddd9cf;background:white;border-radius:7px;padding:5px 2px;font-size:11px;cursor:pointer}.page-tools button:disabled{opacity:.28}.page-tools .remove{color:var(--danger)}.bottom-actions{flex:0 0 auto;padding-top:8px}.capture-actions,.export-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px}.capture-actions.single,.export-actions.single-export{grid-template-columns:1fr}.export-actions{margin-top:8px}.primary-action,.secondary-action{min-height:44px;border-radius:13px;border:1px solid #1d1d1f;font:800 12px inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:7px}.primary-action{background:#1d1d1f;color:#fff}.secondary-action{background:#fff;color:#1d1d1f;border-color:#d7d3ca}.primary-action svg,.secondary-action svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}.export-btn:disabled{opacity:.38;cursor:default}.status{text-align:center;color:#77736a;font-size:10px;line-height:1.25;min-height:0;padding-top:0;transition:.15s}.status:not(:empty){padding-top:6px}.status.error{color:var(--danger)}dialog{width:min(430px,calc(100% - 28px));border:0;border-radius:20px;padding:17px;box-shadow:0 30px 100px #0005;color:#222}dialog::backdrop{background:#1c1c1c66;backdrop-filter:blur(5px)}.dialog-head{display:flex;justify-content:space-between;align-items:center}.dialog-head strong{font-size:17px}dialog p{font-size:12px;line-height:1.55;color:#66625b}.version{font-size:10px;color:#999}.install-btn{width:100%;min-height:42px;border:0;border-radius:12px;background:#1d1d1f;color:#fff;font:800 12px inherit;cursor:pointer}
@media(max-width:580px){.app-shell{padding-left:9px;padding-right:9px;gap:6px}.topbar{height:40px;flex-basis:40px}.mark{width:31px;height:31px;border-radius:10px}.brand{font-size:15px}.document-card{border-radius:19px;padding:10px}.doc-name{font-size:16px;padding-bottom:7px}.empty-visual{width:58px;height:58px;border-radius:18px;margin-bottom:10px}.empty-visual svg{width:35px}.empty-state h1{font-size:17px}.pages-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}.primary-action,.secondary-action{min-height:42px}.bottom-actions{padding-top:7px}.export-actions{margin-top:7px}}
@media(max-height:680px) and (max-width:580px){.topbar{height:36px;flex-basis:36px}.mark{width:29px;height:29px}.document-card{padding:9px}.empty-visual{width:50px;height:50px;margin-bottom:8px}.empty-visual svg{width:31px}.empty-state h1{font-size:16px}.primary-action,.secondary-action{min-height:39px}.capture-actions,.export-actions{gap:6px}.export-actions{margin-top:6px}}
@media(min-width:800px){body{overflow:auto}.app-shell{min-height:100dvh;height:auto;padding-top:24px;padding-bottom:24px}.document-card{min-height:650px;padding:18px}.pages-grid{grid-template-columns:repeat(4,minmax(0,1fr))}}


/* v0.3 — scanner chrome polish. Vision/perspective engine remains untouched. */
[hidden]{display:none!important}
.sds-status{display:none!important}
.sds-tools{gap:10px!important;justify-content:center!important;padding-bottom:9px!important}
.sds-tool{width:42px!important;height:42px!important;padding:0!important;border-radius:12px!important;font-size:0!important;justify-content:center!important;gap:0!important}
.sds-tool svg{width:19px!important;height:19px!important}
.sds-tool[data-action="reset"]::before{content:"";width:19px;height:19px;display:block;background:currentColor;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M4 9V5a1 1 0 0 1 1-1h4M15 4h4a1 1 0 0 1 1 1v4M20 15v4a1 1 0 0 1-1 1h-4M9 20H5a1 1 0 0 1-1-1v-4'/%3E%3C/svg%3E") center/contain no-repeat;-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M4 9V5a1 1 0 0 1 1-1h4M15 4h4a1 1 0 0 1 1 1v4M20 15v4a1 1 0 0 1-1 1h-4M9 20H5a1 1 0 0 1-1-1v-4'/%3E%3C/svg%3E") center/contain no-repeat}
.sds-modes{gap:0!important;width:fit-content!important;max-width:100%!important;margin:0 auto 10px!important;padding:3px!important;border:1px solid #ffffff20!important;border-radius:13px!important;background:#222329!important;overflow:visible!important}
.sds-mode{border:0!important;background:transparent!important;border-radius:10px!important;padding:8px 12px!important}
.sds-mode.active{background:#fff!important;color:#151519!important;box-shadow:0 1px 5px #0003!important}
.sds-bottom:not(.sds-crop) .sds-tools{display:none!important}
.sds-bottom:not(.sds-crop) .sds-actions{width:min(100%,430px)!important;margin:0 auto!important;display:grid!important;grid-template-columns:44px minmax(0,1fr) 44px!important;gap:10px!important;align-items:center!important}
.sds-bottom:not(.sds-crop) [data-action="original"]{order:1!important;width:44px!important;height:44px!important;padding:0!important;font-size:0!important;border-radius:12px!important}
.sds-bottom:not(.sds-crop) [data-action="add"]{order:2!important;width:100%!important;min-width:0!important;justify-self:stretch!important;text-align:center!important}
.sds-bottom:not(.sds-crop) [data-action="apply"]{order:3!important;width:44px!important;height:44px!important;padding:0!important;font-size:0!important;border-radius:12px!important}
.sds-bottom:not(.sds-crop) [data-action="original"]::before{content:"";width:19px;height:19px;display:block;margin:auto;background:currentColor;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='5' width='18' height='14' rx='2' fill='none' stroke='black' stroke-width='2'/%3E%3Ccircle cx='9' cy='10' r='2' fill='black'/%3E%3Cpath d='m4 17 5-5 4 4 3-3 4 4' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='5' width='18' height='14' rx='2' fill='none' stroke='black' stroke-width='2'/%3E%3Ccircle cx='9' cy='10' r='2' fill='black'/%3E%3Cpath d='m4 17 5-5 4 4 3-3 4 4' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat}
.sds-bottom:not(.sds-crop) [data-action="apply"]::before{content:"";width:19px;height:19px;display:block;margin:auto;background:currentColor;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 3v14a4 4 0 0 0 4 4h10M3 7h14a4 4 0 0 1 4 4v10' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 3v14a4 4 0 0 0 4 4h10M3 7h14a4 4 0 0 1 4 4v10' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat}
.sds-bottom.sds-crop .sds-actions{width:min(100%,330px)!important;margin:0 auto!important;display:grid!important;grid-template-columns:44px minmax(0,1fr)!important;gap:10px!important;align-items:center!important}
.sds-bottom.sds-crop [data-action="original"]{width:44px!important;height:44px!important;padding:0!important;font-size:0!important;border-radius:12px!important}
.sds-bottom.sds-crop [data-action="original"]::before{content:"";width:19px;height:19px;display:block;margin:auto;background:currentColor;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='5' width='18' height='14' rx='2' fill='none' stroke='black' stroke-width='2'/%3E%3Ccircle cx='9' cy='10' r='2' fill='black'/%3E%3Cpath d='m4 17 5-5 4 4 3-3 4 4' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='5' width='18' height='14' rx='2' fill='none' stroke='black' stroke-width='2'/%3E%3Ccircle cx='9' cy='10' r='2' fill='black'/%3E%3Cpath d='m4 17 5-5 4 4 3-3 4 4' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat}
.sds-bottom.sds-crop [data-action="apply"]{width:100%!important}
@media(max-width:520px){.sds-bottom{padding-top:8px!important}.sds-modes{margin-bottom:8px!important}.sds-mode{padding:8px 10px!important;font-size:10.5px!important}.sds-bottom:not(.sds-crop) .sds-actions{grid-template-columns:42px minmax(0,1fr) 42px!important;gap:8px!important}.sds-bottom:not(.sds-crop) [data-action="original"],.sds-bottom:not(.sds-crop) [data-action="apply"],.sds-tool{width:42px!important;height:42px!important}}


/* v0.3.1 — scanner controls: one clear primary action per state; engine untouched. */
html,body,button,[role="button"],.app-shell,.sds-overlay,.sds-head,.sds-bottom,.sds-btn,.sds-tool,.sds-mode,.sds-icon{touch-action:manipulation}
.sds-hint{display:none!important}
.sds-stage{padding-bottom:22px!important}
.sds-bottom{padding-top:9px!important}
.sds-tools{gap:8px!important;padding:0 0 8px!important}
.sds-tool{width:40px!important;height:40px!important;border-radius:11px!important;background:#222329!important;border-color:#ffffff22!important}
.sds-tool svg,.sds-tool[data-action="reset"]::before{width:18px!important;height:18px!important}

/* Crop state: two compact tools, then one primary Preview action. */
.sds-bottom.sds-crop .sds-actions{width:min(100%,430px)!important;margin:0 auto!important;display:flex!important;flex-direction:column!important;gap:2px!important;align-items:stretch!important}
.sds-bottom.sds-crop [data-action="apply"]{order:1!important;width:100%!important;min-height:46px!important}
.sds-bottom.sds-crop [data-action="original"]{order:2!important;align-self:center!important;width:auto!important;height:auto!important;min-height:0!important;border:0!important;background:transparent!important;padding:6px 12px 2px!important;border-radius:8px!important;font-size:10px!important;color:#8f9199!important;line-height:1.2!important}
.sds-bottom.sds-crop [data-action="original"]::before{display:none!important}

/* Preview state: modes + one Add action. Crop editing lives on the image itself. */
.sds-bottom:not(.sds-crop) .sds-actions{width:min(100%,430px)!important;margin:0 auto!important;display:block!important}
.sds-bottom:not(.sds-crop) [data-action="original"],
.sds-bottom:not(.sds-crop) [data-action="apply"]{display:none!important}
.sds-bottom:not(.sds-crop) [data-action="add"]{display:block!important;width:100%!important;min-height:46px!important}
.sds-modes{margin:0 auto 8px!important}
.storyline-crop-edit{position:absolute;top:14px;right:14px;z-index:3;width:40px;height:40px;border-radius:12px;border:1px solid #ffffff28;background:#111217cc;color:#fff;display:grid;place-items:center;padding:0;box-shadow:0 5px 18px #0006;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);cursor:pointer;touch-action:manipulation}
.storyline-crop-edit[hidden]{display:none!important}
.storyline-crop-edit svg{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

@media(max-width:520px){
  .sds-bottom{padding-left:max(12px,env(safe-area-inset-left))!important;padding-right:max(12px,env(safe-area-inset-right))!important}
  .sds-bottom.sds-crop .sds-actions,.sds-bottom:not(.sds-crop) .sds-actions{width:100%!important}
  .sds-tool{width:40px!important;height:40px!important}
  .sds-mode{padding:8px 10px!important}
  .storyline-crop-edit{top:10px;right:10px;width:38px;height:38px}
}
