/*
 * Paper Labs V2.0 — Canvas-first shell
 * The legacy component styling stays in styles.css for compatibility.
 * This layer owns the viewport, overlay hierarchy and responsive workspace.
 */
:root {
  --shell-bg:#efeee8;
  --shell-card:#fffef9;
  --shell-ink:#253329;
  --shell-sage:#74926b;
  --shell-line:#e6e6df;
  --shell-shadow:0 18px 55px rgba(20,38,25,.16);
  --shell-header:58px;
}
html, body { height:100%; min-height:0; overflow:hidden; }
body { display:flex; flex-direction:column; padding-bottom:0!important; background:var(--shell-bg); }
[hidden] { display:none!important; }
button { cursor:pointer; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline:2px solid #769c71;
  outline-offset:2px;
}
/* Slim header. The primary canvas receives all remaining viewport space. */
.topbar {
  position:relative;
  top:auto;
  z-index:40;
  height:var(--shell-header);
  min-height:var(--shell-header);
  flex:0 0 var(--shell-header);
  padding:0 20px;
  border-bottom:1px solid var(--shell-line);
  background:var(--shell-card);
  display:flex;
  flex-direction:row;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  box-shadow:none;
}
.topbar .top-actions { display:none!important; }
.brand-lockup { display:flex; gap:11px; align-items:center; min-width:0; }
.brand-symbol {
  width:31px; height:31px; flex:0 0 31px; display:grid; place-items:center;
  border-radius:11px; background:#e6ecdf; color:#3e6748;
  font-size:21px; font-weight:600;
}
.brand-copy {min-width:0;}
.topbar h1 { color:var(--shell-ink); font-size:17px; font-weight:760; line-height:1.22; letter-spacing:-.035em;white-space:nowrap; }
.topbar p { color:#888f82; font-size:10px; font-weight:600; letter-spacing:.025em; margin:2px 0 0; }
.version { margin-left:3px; padding:2px 5px; font-size:9px; vertical-align:middle; color:#66845d; background:#e7efdf; }
.top-utilities { display:flex; align-items:center; gap:9px; min-width:0; }
.topbar .paper-quick-btn {
  max-width:170px; min-height:34px; margin:0; border:1px solid #dde7d8;
  border-radius:12px; padding:7px 11px; background:#f0f5ec;
  color:var(--forest); font-size:12px; font-weight:700;
  text-overflow:ellipsis; overflow:hidden; white-space:nowrap;
}
.header-export-btn { min-height:34px; border:0; border-radius:12px; background:var(--forest); color:#fff; padding:7px 13px; font-size:12px; font-weight:700; }
.header-export-btn span { padding-left:3px; }

.app-grid { position:relative; display:block; flex:1 1 auto; width:100%; height:0; min-height:0; max-height:100%; overflow:hidden; background:var(--shell-bg); }
.app-grid .workspace {
  position:absolute!important; inset:0;
  display:flex!important; flex-direction:column;
  width:100%; height:100%!important; min-height:0!important;
  margin:0!important; padding:0!important;
  overflow:hidden!important; border:0!important; border-radius:0!important;
  background:var(--shell-bg);
}
/* Independent, full-surface paper scroller. */
.app-grid .preview-area {
  position:absolute; inset:0;
  width:100%; height:100%; min-height:0!important; flex:none;
  margin:0!important; padding:68px 22px 111px!important;
  overflow-y:auto; overflow-x:auto;
  border:0!important; border-radius:0!important;
  display:flex!important; flex-direction:column; align-items:center; justify-content:flex-start;
  gap:26px;
  overscroll-behavior:contain;
  background-color:#e8e8df;
  background-image:radial-gradient(#cfd1c5 0.8px,transparent 0.8px);
  background-size:20px 20px;
  scrollbar-color:#bcbeb3 transparent; scrollbar-width:thin;
  -webkit-overflow-scrolling:touch;
}
.page-wrap { flex-shrink:0; max-width:none!important; width:max-content; }
.page-label { margin:0 0 8px; color:#707969; font-size:11px; font-weight:600; }
.paper { flex-shrink:0; max-width:none!important; border-radius:2px; box-shadow:0 9px 26px rgba(37,50,34,.14),0 1px 4px rgba(0,0,0,.06); }
.sticker-selected { outline:2px solid #2e6646!important; outline-offset:0!important; box-shadow:0 0 0 3px rgba(105,158,110,.25); }
/* Status is a floating chip; it never takes layout height. */
.workspace .workspace-toolbar {
  position:absolute!important; top:12px; left:14px; right:14px; z-index:11;
  width:auto; height:auto; min-height:0;
  margin:0!important; padding:0!important; display:flex!important; flex-direction:row;
  align-items:start; justify-content:space-between; gap:9px;
  border:0!important; border-radius:0!important; background:transparent!important;
  box-shadow:none!important; pointer-events:none;
}
.workspace-toolbar>div:first-child {
  width:auto!important; min-height:34px; display:flex!important; align-items:center; gap:6px;
  padding:7px 11px; border:1px solid rgba(217,221,210,.85); border-radius:11px;
  background:rgba(255,254,249,.95); box-shadow:0 5px 20px rgba(44,63,45,.075);
  backdrop-filter:blur(10px); pointer-events:auto;
}
.workspace-toolbar strong { font-size:11px; color:#5d6c5f; font-weight:700; white-space:nowrap; }
.workspace-toolbar .warning {font-size:11px; margin:0;}
.workspace-toolbar .toolbar-actions {display:none!important;}
.workspace-toolbar #pageNav {
  width:auto!important; display:flex; align-items:center; pointer-events:auto;
  padding:0; margin:0; flex:0 0 auto; justify-content:end;
}
.workspace-toolbar #pageNav.hidden {display:none!important;}
.workspace-toolbar #pageNav #prevPageBtn,
.workspace-toolbar #pageNav #nextPageBtn {display:none!important;}
.workspace-toolbar #pageNav select {
  min-width:101px; max-width:115px; width:110px; min-height:34px; padding:7px 9px;
  border:1px solid rgba(217,221,210,.85); border-radius:11px;
  background:rgba(255,254,249,.95); font-size:11px; font-weight:700; color:#5d6c5f;
  box-shadow:0 5px 20px rgba(44,63,45,.075);
}
/* Subtle warning only when necessary. */
.workspace .layout-issue-panel {
  position:absolute;top:53px;left:14px;right:14px;z-index:14;
  margin:0;padding:9px 12px;max-width:580px;min-height:40px;
  border:1px solid #ecd6cb;border-radius:13px;box-shadow:0 8px 22px rgba(75,45,40,.08);
  background:#fff7ef;
}
/* Canvas dock: always a floating element above paper, not a full-width footer. */
.canvas-dock {
  position:absolute;bottom:calc(17px + env(safe-area-inset-bottom));left:50%;
  transform:translateX(-50%);z-index:32;
  width:max-content;max-width:calc(100% - 20px);
  display:flex;align-items:center;justify-content:center;gap:4px;
  padding:6px;border:1px solid rgba(220,228,215,.9);border-radius:20px;
  background:rgba(255,254,250,.96);box-shadow:0 12px 32px rgba(31,46,31,.17);
  backdrop-filter:blur(16px);
}
.dock-button { min-width:65px; min-height:50px; border:0;border-radius:14px; background:transparent;color:#5c715f;
  padding:5px 9px 4px; display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;
  font-size:10px;font-weight:720;line-height:1.1; white-space:nowrap;
}
.dock-button:hover,.dock-button.active,.dock-button[aria-pressed="true"] {background:#e9f0e4;color:#244d32;}
.dock-icon {font-size:20px;line-height:22px;font-weight:600;}
.dock-button.dock-add {color:#27513a;}
.dock-button.dock-export {background:var(--forest);color:white;min-width:68px;}
.dock-button.dock-export:hover {background:#345d3b;}
.selection-mini {
  position:absolute;bottom:calc(89px + env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);
  z-index:33;width:max-content;max-width:calc(100% - 24px);display:flex;align-items:center;gap:3px;
  padding:4px;border:1px solid #d6e2d1;border-radius:15px;
  background:#f9fdf4;box-shadow:0 9px 28px rgba(25,48,26,.15);
}
.selection-mini-open {border:0;background:transparent;padding:9px 10px;color:#30543c;font-size:12px;font-weight:700;white-space:nowrap;}
.selection-mini-open strong {font-weight:800;font-variant-numeric:tabular-nums;}
.selection-mini-open span {margin-left:3px;}
.selection-mini-clear {width:33px;height:33px;border:0;border-radius:10px;background:#e8eee5;color:#5b7060;font-size:21px;}

/* Sliding work drawers never push or resize the paper preview. */
.app-grid > .panel {
  position:absolute!important;top:0;bottom:0;z-index:61;
  display:flex!important;flex-direction:column;
  width:min(372px, 94vw);height:100%!important;max-height:100%;
  min-height:0!important; margin:0!important; padding:22px 20px!important;
  overflow-y:auto;overscroll-behavior:contain;
  border:0!important;border-radius:0!important;
  background:#fcfaf3;box-shadow:var(--shell-shadow);
  transition:transform .24s ease;pointer-events:none;
}
.app-grid > .left-panel {left:0;right:auto;transform:translateX(-108%);}
.app-grid > .right-panel {right:0;left:auto;transform:translateX(108%);}
.app-grid > .panel.drawer-visible {transform:translateX(0)!important;pointer-events:auto!important;}
.app-grid .left-panel > section {display:flex;flex:1 1 auto;flex-direction:column;min-height:0;}
.app-grid .left-panel .asset-list {flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding-bottom:18px;}
.app-grid .right-panel {display:block!important;}
.app-grid .right-panel section {background:#fffefa;border:1px solid #efeee7;box-shadow:none;padding:17px;margin:0 0 12px;border-radius:18px;}
.drawer-backdrop {position:absolute;inset:0;z-index:55;background:rgba(15,30,20,.32);backdrop-filter:blur(1px);}
.drawer-backdrop:not(.hidden) {display:block;}
.drawer-handle {display:none;}
.panel-header,.section-title-row {display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:13px;}
.panel-header h2,.section-title-row h2 {font-size:19px;margin:0;color:#263b2a;}
.section-title-row h2 small {display:block;font-size:10px;font-weight:600;color:#87917f;margin-top:3px;}
.panel-header .sheet-kicker,.sheet-kicker {display:block;color:#86a37b;font-size:9px;font-weight:800;letter-spacing:.13em;margin-bottom:3px;}
.drawer-close {width:34px;height:34px;flex:0 0 34px;border:0;border-radius:11px;background:#edf0e9;color:#3a5d40;font-size:22px;line-height:1;}
/* Close control in asset list moves the add button to its own row. */
.left-panel .section-title-row {display:grid;grid-template-columns:minmax(0,1fr) auto;}
.left-panel .section-title-row .file-button {grid-column:1 / -1;grid-row:2;width:100%;min-height:43px;}
.left-panel .section-title-row .drawer-close {grid-column:2;grid-row:1;}
.left-panel .section-title-row h2 {grid-column:1;grid-row:1;}
.duplicate-tip {border-radius:12px;}

/* All editing controls live in this sheet; selection bar no longer consumes canvas height. */
.selection-sheet-backdrop {position:fixed;inset:0;z-index:155;display:flex;align-items:center;justify-content:center;background:rgba(17,33,20,.35);backdrop-filter:blur(2px);}
.selection-sheet {width:min(525px,calc(100vw - 24px));max-height:min(78dvh,700px);overflow-y:auto;padding:21px 20px 22px;border-radius:24px;background:#fffcf5;box-shadow:var(--shell-shadow);}
.sheet-heading {display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px;}
.sheet-heading h2 {font-size:19px;margin:0;color:#29452f;}
.selection-sheet .selection-toolbar {
  position:static!important;width:100%;height:auto;max-height:none!important;display:flex;flex-direction:column;align-items:stretch;
  gap:15px;overflow:visible!important;margin:0!important;padding:0!important;border:0!important;
  border-radius:0!important;background:transparent!important;box-shadow:none!important;
}
.selection-sheet .selection-toolbar.hidden {display:none!important;}
.selection-sheet .selection-status {font-size:12px;color:#607361;width:100%;padding-bottom:3px;}
.selection-sheet .selection-group {width:100%;flex-wrap:wrap;overflow:visible;gap:8px;padding:0;}
.selection-sheet .selection-label {min-width:45px;font-size:11px;color:#687868;}
.selection-sheet .quick-size-group {display:grid;grid-template-columns:repeat(5, minmax(0,1fr));}
.selection-sheet .quick-size-group .selection-label {grid-column:1/-1;}
.selection-sheet .quick-size-group .quick-size-btn {padding:9px 2px;min-width:0;font-size:11px;}
.selection-sheet .selection-divider {display:none;}
.selection-sheet .selection-hint {font-size:11px;color:#748073;line-height:1.5;}
.selection-sheet .custom-size-group {gap:8px;}
.selection-sheet .custom-size-group label {flex:1;}
.selection-sheet .custom-size-group input {min-width:90px;}
.selection-sheet .selection-delete-group {order:10;padding-top:11px;border-top:1px solid #e5e9df;}
.selection-sheet .selection-delete-group button {width:100%;min-height:43px;}
/* Modal family: visual language and padding harmonized. */
.paper-sheet-backdrop,.export-sheet-backdrop {background:rgba(15,30,20,.38);backdrop-filter:blur(3px);}
.export-sheet-backdrop:not(.hidden) {display:flex!important;}
.export-sheet-backdrop {align-items:center;}
.paper-sheet,.export-sheet {width:min(490px,calc(100vw - 24px));max-height:min(82dvh,750px);padding:21px;border-radius:24px;overflow-y:auto;background:#fffcf5;box-shadow:var(--shell-shadow);}
.paper-choice {border-radius:12px;min-height:43px;}
.export-sheet .export-action {box-shadow:none;border:1px solid #ebeee5;min-height:62px;}
.export-sheet .export-action-primary {border:0;}
.export-sheet-section {margin-top:13px;}
.export-sheet-cancel {margin-top:14px;}
.mobile-export-fab,.mobile-nav,.asset-spotlight {display:none!important;}
.undo-toast {bottom:calc(93px + env(safe-area-inset-bottom));z-index:140;}
.empty-canvas {
  margin:auto!important;display:flex;flex-direction:column;align-items:center;justify-content:center;
  width:min(430px,100%);min-height:360px;padding:28px!important;
  border:1px solid #e0e6d9!important;border-radius:20px!important;background:rgba(255,254,250,.97)!important;
  box-shadow:0 10px 30px rgba(43,54,40,.09)!important;
}
.empty-icon {width:64px;height:64px;display:grid;place-items:center;border:1px dashed #9dbb91;border-radius:18px;background:#eaf0e4;color:#4d7953;font-size:32px;margin-bottom:14px;}
.empty-canvas h2 {font-size:19px;color:#2c4632;margin:5px 0 9px;}
.empty-canvas p {font-size:12px;color:#758074;line-height:1.6;max-width:265px;margin:0 0 17px;}
.empty-add-button {border:0;border-radius:13px;background:var(--forest);color:white;min-height:44px;padding:11px 28px;font-size:13px;font-weight:750;}

@media (max-width:760px) {
  :root {--shell-header:48px;}
  html {font-size:16px;-webkit-text-size-adjust:100%;}
  html, body {height:100dvh;}
  body {height:100dvh;min-height:0!important;overflow:hidden!important;padding:0!important;}
  .topbar {
    position:relative!important;height:var(--shell-header)!important;min-height:var(--shell-header)!important;
    flex:0 0 var(--shell-header)!important;padding:0 11px!important;
    flex-direction:row!important;justify-content:space-between!important;align-items:center!important;
    gap:7px!important;border-radius:0!important;
  }
  .brand-lockup {gap:7px;}
  .brand-symbol {width:28px;height:28px;flex-basis:28px;border-radius:9px;font-size:18px;}
  .topbar h1 {font-size:15px!important;white-space:nowrap;}
  .topbar p,.topbar .version,.header-export-btn {display:none!important;}
  .top-utilities {gap:5px;}
  .topbar .paper-quick-btn {max-width:117px;min-width:0;min-height:30px;padding:6px 9px;font-size:11px;text-align:center;}
  .app-grid {display:block!important;height:0!important;min-height:0!important;flex:1 1 auto;overflow:hidden;}
  .app-grid > .workspace {
    display:flex!important;position:absolute!important;inset:0;
    height:100%!important;min-height:0!important;margin:0!important;padding:0!important;overflow:hidden!important;
    border-radius:0!important;
  }
  .app-grid .preview-area {
    display:flex!important;position:absolute!important;inset:0;
    height:100%!important;width:100%;min-height:0!important;
    margin:0!important;padding:50px 8px calc(86px + env(safe-area-inset-bottom))!important;
    border-radius:0!important;gap:18px;
    overflow-y:auto;overflow-x:auto;
  }
  .page-wrap {max-width:none!important;width:max-content;}
  .page-label {margin-bottom:6px;font-size:10px;}
  .paper {max-width:none!important;border-radius:1px;box-shadow:0 6px 20px rgba(50,60,45,.16);}
  .workspace .workspace-toolbar {top:8px;left:8px;right:8px;gap:5px;}
  .workspace-toolbar > div:first-child {padding:6px 8px;min-height:30px;border-radius:9px;}
  .workspace-toolbar strong {font-size:10px;}
  .workspace-toolbar .warning {display:none;}
  .workspace-toolbar #pageNav select {min-height:30px;width:95px;min-width:93px;max-width:99px;font-size:10px;padding:4px 6px;border-radius:9px;}
  .workspace .layout-issue-panel {top:44px;left:8px;right:8px;font-size:11px;}
  .canvas-dock {bottom:calc(9px + env(safe-area-inset-bottom));padding:4px;border-radius:17px;gap:1px;width:min(337px,calc(100% - 16px));max-width:none;}
  .dock-button {min-width:0;flex:1 1 0;min-height:49px;padding:4px 3px;font-size:10px;border-radius:13px;}
  .dock-icon {font-size:19px;line-height:20px;}
  .dock-button.dock-export {min-width:0;flex:1 1 0;}
  .selection-mini {bottom:calc(71px + env(safe-area-inset-bottom));max-width:calc(100% - 18px);}
  .selection-mini-open {font-size:11px;padding:8px 7px;}
  .undo-toast {bottom:calc(77px + env(safe-area-inset-bottom));}
  /* Mobile drawers are bottom sheets, not independent pages that hide the canvas. */
  .app-grid > .panel,
  .app-grid > .left-panel,
  .app-grid > .right-panel {
    display:flex!important;position:absolute!important;top:auto!important;right:0;left:0;bottom:0;
    flex-direction:column;width:100%;max-width:100%;
    height:min(82dvh,780px)!important;max-height:82dvh!important;min-height:0!important;
    margin:0!important;padding:14px 15px calc(18px + env(safe-area-inset-bottom))!important;
    overflow-y:auto!important;overscroll-behavior:contain;
    border-radius:24px 24px 0 0!important;
    transform:translateY(110%)!important;pointer-events:none;
    transition:transform .24s ease;
  }
  .app-grid > .panel.drawer-visible {transform:translateY(0)!important;pointer-events:auto!important;}
  .app-grid .left-panel>section {display:flex;flex-direction:column;min-height:0;flex:1 1 auto;}
  .app-grid .left-panel .asset-list {flex:1 1 auto;min-height:0;overflow-y:auto;padding-bottom:20px;}
  .app-grid .right-panel {display:block!important;}
  .drawer-handle {display:block;width:38px;height:4px;flex:0 0 4px;border-radius:999px;background:#d7decf;margin:0 auto 14px;}
  .app-grid .right-panel .drawer-handle {margin:0 auto 15px;}
  .panel-header h2 {font-size:19px;}
  .section-title-row h2 {font-size:19px;}
  .selection-sheet-backdrop {align-items:flex-end;}
  .selection-sheet {width:100%;max-height:78dvh;padding:13px 16px calc(18px + env(safe-area-inset-bottom));border-radius:24px 24px 0 0;}
  .selection-sheet .drawer-handle {margin:0 auto 13px;}
  .selection-sheet .selection-toolbar {max-height:none;overflow:visible!important;gap:13px;}
  .selection-sheet .selection-group {width:100%;overflow:visible;flex-wrap:wrap;}
  .selection-sheet .quick-size-group {display:grid;grid-template-columns:repeat(5,minmax(0,1fr));}
  .selection-sheet .quick-size-group .quick-size-btn {min-height:40px;flex:1 1 auto;}
  .selection-sheet .custom-size-group {align-items:center;}
  .selection-sheet .custom-size-group input {font-size:16px;}
  .paper-sheet-backdrop,.export-sheet-backdrop {align-items:flex-end;}
  .paper-sheet,.export-sheet {width:100%;max-height:82dvh;min-height:0;padding:18px 15px calc(18px + env(safe-area-inset-bottom));border-radius:24px 24px 0 0;}
  .export-sheet {max-height:84dvh;}
  .paper-sheet::before {content:"";display:block;width:38px;height:4px;background:#d7decf;border-radius:8px;margin:0 auto 15px;}
  .paper-choice-grid {grid-template-columns:repeat(3,minmax(0,1fr));}
  .paper-choice {min-height:46px;padding:9px 3px;font-size:12px;}
  .export-action {min-height:62px;}
  .empty-canvas {min-height:305px;width:min(345px,100%);padding:21px!important;}
  .empty-canvas h2 {font-size:17px;}
  input,select,textarea {font-size:16px;}
}
@media (max-width:370px) {
  .brand-symbol {display:none;}
  .topbar h1 {font-size:14px!important;}
  .topbar .paper-quick-btn {font-size:10px;max-width:105px;}
  .dock-button {font-size:9px;}
  .dock-icon {font-size:17px;}
  .workspace-toolbar strong {font-size:9px;}
}
@media (prefers-reduced-motion:reduce) {
 .app-grid > .panel,.sticker,.btn {transition:none!important;}
}

/* Non-blocking import feedback beside the floating dock. */
.canvas-toast {
  position:absolute;bottom:calc(99px + env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);
  z-index:35;display:block;width:max-content;max-width:min(580px,calc(100% - 26px));
  padding:10px 15px;border:1px solid #d7e7d2;border-radius:13px;
  background:rgba(249,253,246,.97);color:#315b36;box-shadow:0 10px 26px rgba(31,54,35,.16);
  font-size:12px;font-weight:680;text-align:center;line-height:1.45;
}
@media(max-width:760px) {.canvas-toast {bottom:calc(74px + env(safe-area-inset-bottom));font-size:11px;padding:9px 12px;}}

/* V2.1: ultra-dense layout mode, settings drawer only; canvas size unchanged. */
.dense-layout-options {
  margin:5px 0 14px;
  padding:12px 14px;
  border:1px solid #d7e4d0;
  border-radius:15px;
  background:#f2f6ee;
}
.dense-layout-options .check-row { margin:0 0 7px; align-items:flex-start; line-height:1.45; }
.dense-layout-options .check-row input { flex:0 0 auto; margin-top:3px; }
.dense-layout-options .helper-text { margin:5px 0 0; line-height:1.5; font-size:12px; }
