  :root{
    --bg:#16140f;
    --panel:#201d17;
    --panel-2:#272319;
    --line:#3a3326;
    --text:#ece6d8;
    --text-dim:#a89c84;
    --amber:#e3922b;
    --amber-dim:#7a5524;
    --amber-hover:#f0a546;
    --danger:#c4654a;
    --label-color:var(--amber);
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
    --sans: -apple-system, "Segoe UI", system-ui, sans-serif;
  }
  :root[data-theme="light"]{
    --bg:#f3ecdb;
    --panel:#fbf6e9;
    --panel-2:#ffffff;
    --line:#d9cdab;
    --text:#6b5640;
    --text-dim:#73633f;
    --amber:#e2941a;
    --amber-dim:#e8cc9a;
    --amber-hover:#c97f12;
    --danger:#a8432b;
    --label-color:#9c6212;
  }
  *{box-sizing:border-box;}
  html,body{margin:0;padding:0;}
  body{
    background:var(--bg);
    color:var(--text);
    font-family:var(--sans);
    min-height:100vh;
  min-height:100svh;
    display:flex;
    flex-direction:column;
    position:relative;
  }

  #ambient-bg{
    position:fixed;
    inset:0;
    z-index:0;
    overflow:hidden;
    pointer-events:none;
    color:var(--text-dim);
  }
  #ambient-bg svg{
    position:absolute;
    bottom:-70px;
    right:-70px;
    width:560px;
    height:560px;
    opacity:0.05;
  }
  header, main, footer{
    position:relative;
    z-index:1;
  }

  .icon-glyph{
    display:block;
  }
  @media (prefers-reduced-motion: reduce){
    *{transition:none !important; animation:none !important;}
  }

  header{
    display:flex;
    align-items:baseline;
    justify-content:space-between;
    padding:18px 24px;
    border-bottom:1px solid var(--line);
    flex-wrap:wrap;
    gap:8px;
  }
  header .brand{
    display:flex;
    align-items:baseline;
    gap:10px;
  }
  header h1{
    font-size:26px;
    font-weight:700;
    margin:0;
    letter-spacing:0.01em;
  }
  header h1 .dot{ color:var(--amber); }
  header .tagline{
    font-size:15px;
    color:var(--text-dim);
  }
  #stats{
    font-family:var(--mono);
    font-size:16px;
    font-weight:600;
    color:var(--text);
    text-align:right;
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:8px;
    padding:7px 12px;
  }
  #stats:empty{ display:none; }
  #stats .saved{ color:var(--amber); }

  main{
    flex:1;
    display:flex;
    flex-direction:column;
    align-items:center;
    padding:24px;
    gap:20px;
  }

  #stage-wrap{
    position:relative;
    width:100%;
    max-width:920px;
  }
  #dropzone{
    border:1.5px dashed var(--line);
    border-radius:10px;
    background:var(--panel);
    min-height:280px;
    display:flex;
    align-items:center;
    justify-content:center;
    transition:border-color 120ms, box-shadow 120ms;
  }
  #dropzone.drag, #dropzone.active{
    border-color:var(--amber);
    box-shadow:0 0 0 1px var(--amber-dim), 0 0 24px -4px var(--amber-dim);
  }
  #empty-state{
    text-align:center;
    color:var(--text-dim);
    padding:40px 24px;
  }
  #empty-state .icon-glyph{
    width:56px;
    height:56px;
    margin:0 auto 14px;
    color:var(--text-dim);
  }
  #empty-state p{ margin:0 0 14px; font-size:14px; }
  #touch-paste-target{
    outline:none;
    border-radius:8px;
    transition:background .15s, box-shadow .15s;
  }
  #touch-paste-target:focus{
    background:var(--panel-2);
    box-shadow:0 0 0 2px var(--amber-dim);
  }
  #empty-state kbd{
    font-family:var(--mono);
    background:var(--panel-2);
    border:1px solid var(--line);
    border-radius:4px;
    padding:2px 6px;
    font-size:12px;
  }
  #choose-btn{
    margin-top:6px;
  }

  #canvas-area{
    display:none;
    position:relative;
    width:100%;
  }
  #canvas-area.show{ display:block; }

  /* Zoom/pan viewport wrapper */
  #canvas-viewport{
    width:100%;
    overflow:auto;
    border-radius:8px;
    position:relative;
    background:#0c0b08;
    cursor:default;
    /* scrollbar hidden visually but functional */
    scrollbar-width:none;
  }
  #canvas-viewport::-webkit-scrollbar{ display:none; }
  #canvas-viewport.panning{ cursor:grabbing !important; }
  #canvas-viewport.long-pressing canvas{
    opacity:.75;
    transition:opacity .15s;
  }
  #canvas-viewport.pan-ready{ cursor:grab; }

  /* Inner scroll container — expands when zoomed */
  #canvas-scroll{
    position:relative;
    transform-origin:top left;
    /* width/height set by JS to canvas display size * zoom */
  }

  canvas{
    display:block;
    border-radius:0;
    background:#0c0b08;
    /* actual display dimensions set by JS */
  }

  /* Zoom controls bar */
  #zoom-bar{
    display:none;
    align-items:center;
    gap:4px;
    padding:6px 0 4px;
    -webkit-user-select:none;
    user-select:none;
  }
  #zoom-bar.show{ display:flex; }

  #zoom-bar button{
    width:30px; height:30px;
    font-size:18px; line-height:1;
    border:1px solid var(--line);
    border-radius:7px;
    background:var(--panel-2);
    color:var(--text);
    cursor:pointer;
    display:flex; align-items:center; justify-content:center;
    flex-shrink:0;
    transition:background .12s, border-color .12s, color .12s;
  }
  #zoom-bar button:hover:not(:disabled){
    background:var(--amber);
    border-color:var(--amber);
    color:#fff;
  }
  #zoom-bar button:active:not(:disabled){ opacity:.8; }
  #zoom-bar button:disabled{
    opacity:.35;
    cursor:default;
  }

  #zoom-percent{
    min-width:48px;
    text-align:center;
    font-size:13px;
    font-weight:600;
    color:var(--text);
    background:var(--panel-2);
    border:1px solid var(--line);
    border-radius:7px;
    padding:0 6px;
    height:30px;
    line-height:30px;
    letter-spacing:.01em;
  }

  #zoom-fit-btn{
    font-size:12px !important;
    font-weight:600 !important;
    width:auto !important;
    padding:0 10px !important;
    letter-spacing:.02em;
  }

  /* Zoom hint label */
  #zoom-hint{
    font-size:11px;
    color:var(--text-dim);
    margin-left:4px;
  }
  #crop-overlay{
    position:absolute;
    inset:0;
    cursor:crosshair;
    display:none;
    touch-action:none;
  }
  #crop-overlay.show{ display:block; }
  #selection-box{
    position:absolute;
    border:1.5px solid var(--amber);
    background:rgba(227,146,43,0.14);
    display:none;
    pointer-events:none;
  }

  #crop-actions{
    display:none;
    gap:8px;
    margin-top:10px;
    justify-content:center;
  }
  #crop-actions.show{ display:flex; }

  #annotate-overlay{
    position:absolute;
    inset:0;
    cursor:crosshair;
    display:none;
    touch-action:none;
  }
  #annotate-overlay.show{ display:block; }
  #annotate-preview-box{
    position:absolute;
    display:none;
    pointer-events:none;
    box-sizing:border-box;
  }
  #annotate-select-box{
    position:absolute;
    display:none;
    pointer-events:none;
    box-sizing:border-box;
    border:1px dashed #fff;
    box-shadow:0 0 0 1px rgba(0,0,0,0.65);
  }
  #annotate-overlay.move-tool{ cursor:default; }
  #annotate-overlay.moving{ cursor:grabbing; }
  #annotate-preview-line{
    position:absolute;
    display:none;
    pointer-events:none;
    height:4px;
    border-radius:2px;
    transform-origin:0 50%;
  }
  .annotate-text-wrap{
    position:absolute;
    z-index:5;
    display:inline-flex;
    flex-direction:column;
  }
  .annotate-text-input{
    background:var(--annot-bg);
    border:1px dashed var(--annot-border);
    border-bottom:none;
    border-radius:4px 4px 0 0;
    padding:4px 8px;
    font:600 18px sans-serif;
    line-height:1.25;
    min-width:120px;
    min-height:2.5em;
    width:200px;
    resize:none;
    outline:none;
    overflow:hidden;
    white-space:pre-wrap;
    word-break:break-word;
    box-sizing:border-box;
  }
  .annotate-text-resizer{
    height:10px;
    background:var(--annot-bg);
    border:1px dashed var(--annot-border);
    border-top:1px solid var(--annot-border);
    border-radius:0 0 4px 4px;
    cursor:nwse-resize;
    display:flex;
    align-items:center;
    justify-content:flex-end;
    padding-right:4px;
    box-sizing:border-box;
    touch-action:none;
  }
  .annotate-text-resizer::after{
    content:'⠿';
    font-size:10px;
    color:var(--annot-border);
    line-height:1;
  }
  .annotate-text-input::placeholder{
    color:var(--annot-border);
    font-weight:400;
    font-size:0.8em;
  }
  :root{
    --annot-bg:rgba(22,20,15,0.72);
    --annot-border:rgba(255,255,255,0.55);
  }
  :root[data-theme="light"]{
    --annot-bg:rgba(243,236,219,0.82);
    --annot-border:rgba(107,86,64,0.55);
  }
  #annotate-actions{
    display:none;
    flex-wrap:wrap;
    gap:8px;
    margin-top:10px;
    align-items:center;
    justify-content:center;
  }
  #annotate-actions.show{ display:flex; }
  /* Desktop-only annotate tools: hidden on phones, touch tablets and narrow windows */
  .wide-only{ display:none; }
  .tool-group{ display:contents; }
  #annotate-frame-mode{ display:none; gap:4px; align-items:center; padding:0; }
  #annotate-preview-pen{ position:absolute; inset:0; width:100%; height:100%; display:none; pointer-events:none; overflow:visible; }
  #annotate-hl-mode{ display:none; gap:4px; align-items:center; padding:0 4px; }
  #annotate-obf-mode{ display:none; gap:4px; align-items:center; padding:0 4px; }
  #annotate-sizes{
    display:flex;
    gap:4px;
    align-items:center;
    padding:0 4px;
  }
  #annotate-sizes .size-btn{ min-width:34px; }
  #annotate-colors{
    display:flex;
    gap:6px;
    align-items:center;
    padding:0 4px;
  }
  .color-swatch{
    width:22px;
    height:22px;
    border-radius:50%;
    border:2px solid var(--line);
    padding:0;
    cursor:pointer;
  }
  .color-swatch.active{
    border-color:var(--text);
  }
  /* Per-swatch colors — previously inline style="background:..." on
     each button, moved here so the color is set once per swatch
     rather than duplicated as both a data attribute (read by JS,
     see annotateColor logic) and an inline style (purely visual). */
  .color-swatch[data-color="#ffe600"]{ background:#ffe600; }
  .color-swatch[data-color="#ff2e92"]{ background:#ff2e92; }
  .color-swatch[data-color="#00d4ff"]{ background:#00d4ff; }
  .color-swatch[data-color="#ff3b30"]{ background:#ff3b30; }
  .color-swatch[data-color="#76ff03"]{ background:#76ff03; }

  /* Was inline style="width:64px" on #target-size-input / #pdf-target-input */
  .target-input-width{
    width:64px;
  }

  #side{ display:contents; }
  #controls{
    width:100%;
    max-width:920px;
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:10px;
    padding:18px 20px;
    display:none;
    flex-direction:column;
    gap:16px;
  }
  #controls.show{ display:flex; }

  .row{
    display:flex;
    align-items:center;
    gap:14px;
    flex-wrap:wrap;
  }
  .label{
    font-size:14px;
    letter-spacing:0.06em;
    text-transform:uppercase;
    color:var(--label-color);
    width:128px;
    flex-shrink:0;
  }
  .row input[type=range]{
    flex:1;
    min-width:140px;
    accent-color:var(--amber);
  }
  .row .value{
    font-family:var(--mono);
    font-size:12px;
    color:var(--text-dim);
    width:42px;
    text-align:right;
    flex-shrink:0;
  }
  .row .spacer{ flex:1 1 auto; }
  .presets{ display:flex; gap:6px; }
  .hint{
    font-size:13px;
    color:var(--text-dim);
    min-width:0;
    flex:1 1 auto;
  }

  button{
    font-family:var(--sans);
    font-size:13px;
    border-radius:7px;
    border:1px solid var(--line);
    background:var(--panel-2);
    color:var(--text);
    padding:8px 14px;
    cursor:pointer;
    transition:background 100ms, border-color 100ms;
  }
  button:hover{ border-color:var(--text-dim); }
  button:focus-visible{
    outline:2px solid var(--amber);
    outline-offset:2px;
  }
  button.small{ padding:5px 10px; font-size:14px; }
  button.primary{
    background:var(--amber);
    border-color:var(--amber);
    color:#1c1304;
    font-weight:600;
  }
  button.primary:hover{ background:var(--amber-hover); }
  button.ghost{
    background:transparent;
  }
  button.danger{
    background:var(--danger);
    border-color:var(--danger);
    color:#fff;
    font-weight:600;
  }
  button.danger:hover{ filter:brightness(1.12); }
  button.active{
    border-color:var(--amber);
    color:var(--amber);
  }
  button:disabled{
    opacity:0.4;
    cursor:not-allowed;
  }

  #actions{
    width:100%;
    max-width:920px;
    display:flex;
    justify-content:center;
    gap:10px;
    flex-wrap:wrap;
  }
  #actions .spacer{ flex:1; max-width:40px; }

  #toast{
    position:fixed;
    bottom:24px;
    bottom:max(24px, calc(env(safe-area-inset-bottom) + 16px));
    left:50%;
    transform:translateX(-50%) translateY(20px);
    background:var(--panel-2);
    border:1px solid var(--amber-dim);
    color:var(--text);
    padding:10px 18px;
    border-radius:8px;
    font-size:13px;
    max-width:90vw;
    text-align:center;
    z-index:1000;
    opacity:0;
    pointer-events:none;
    transition:opacity 160ms, transform 160ms;
  }
  #toast.error{ border-color:var(--danger); }
  #toast.show{
    opacity:1;
    transform:translateX(-50%) translateY(0);
  }

  footer{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    text-align:center;
    margin:0 auto 16px;
    padding:9px 18px;
    width:fit-content;
    font-size:13px;
    color:var(--text-dim);
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:999px;
  }
  footer .footer-icon{
    width:15px;
    height:15px;
    flex-shrink:0;
    color:var(--amber);
  }

  #file-input, #explorer-file-input, #pdf-file-input{ display:none; }

  /* --- tabs & mode panels --- */
  .tabs{
    display:flex;
    gap:4px;
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:8px;
    padding:3px;
  }
  .tab{
    border:none;
    background:transparent;
    color:var(--text-dim);
    padding:6px 14px;
    border-radius:6px;
    font-size:13px;
  }
  .tab:hover{ border-color:transparent; color:var(--text); }
  .tab.active{
    background:var(--amber);
    color:#1c1304;
    font-weight:600;
  }

  #theme-toggle{
    width:34px;
    height:34px;
    padding:0;
    border-radius:8px;
    background:var(--panel);
    border:1px solid var(--line);
    color:var(--text-dim);
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
  }
  #theme-toggle:hover{ border-color:var(--amber-dim); color:var(--text); }
  #theme-toggle svg{ width:17px; height:17px; }
  /* icon shows the chosen mode: auto (default), light or dark */
  #theme-toggle .icon-sun, #theme-toggle .icon-moon{ display:none; }
  :root[data-theme-mode="light"] #theme-toggle .icon-sun{ display:block; }
  :root[data-theme-mode="dark"] #theme-toggle .icon-moon{ display:block; }
  :root[data-theme-mode="light"] #theme-toggle .icon-auto,
  :root[data-theme-mode="dark"] #theme-toggle .icon-auto{ display:none; }

  #lang-select{
    height:34px;
    border-radius:8px;
    background:var(--panel);
    border:1px solid var(--line);
    color:var(--text-dim);
    font-size:14px;
    font-family:var(--mono);
    padding:0 8px;
    flex-shrink:0;
  }
  #lang-select:hover{ border-color:var(--amber-dim); color:var(--text); }

  /* ===== Wide-screen desktop layout: canvas left, controls in side panel =====
     Phones, touch tablets and narrow windows keep the single-column layout. */
  @media (min-width:1100px) and (pointer:fine){
    main{ padding:16px 24px; }
    #quick-mode.active{
      display:grid;
      grid-template-columns:minmax(0,1fr) 340px;
      column-gap:20px;
      row-gap:14px;
      align-items:start;
    }
    #quick-mode #stage-wrap{ grid-column:1; grid-row:1 / -1; max-width:none; }
    /* One sticky column: tools scroll inside it, action buttons stay visible below */
    #quick-mode #side{
      display:flex; flex-direction:column; gap:14px;
      grid-column:2; grid-row:1 / -1;
      position:sticky; top:16px; align-self:start;
      max-height:calc(100vh - 32px);
    }
    #quick-mode #controls{
      max-width:none; flex:0 1 auto; min-height:0; overflow:auto;
    }
    #quick-mode #actions{
      max-width:none; flex:0 0 auto;
      justify-content:flex-start;
    }
    #quick-mode #actions .spacer{ display:none; }
    #quick-mode #actions #copy-btn{ flex:1 0 100%; }
    #dropzone{ min-height:60vh; }
  }
  @media (min-width:1100px) and (pointer:fine){
    .wide-only{ display:revert; }
    .tool-group{ display:flex; }
    #annotate-obf-mode.show{ display:flex; }
    #annotate-hl-mode.show{ display:flex; }
    #annotate-frame-mode.show{ display:flex; }
    /* Tool group: main button with its sub-options in a row below it, boxed while that tool is active */
    #annotate-actions{ align-items:flex-start; }
    #annotate-actions > :not(.tool-group){ margin-top:4px; }
    .tool-group{
      display:flex; flex-direction:column; align-items:flex-start; gap:6px;
      border:1px solid transparent; border-radius:8px; padding:3px;
    }
    .tool-group.open{ border-color:var(--amber-dim); background:transparent; }
    #annotate-hl-mode, #annotate-obf-mode{ padding:0; }
  }
  .mode-panel{ display:none; width:100%; }
  .mode-panel.active{ display:flex; flex-direction:column; align-items:center; gap:20px; }

  /* --- explorer dropzone --- */
  #explorer-dropzone{
    width:100%;
    max-width:920px;
    border:1.5px dashed var(--line);
    border-radius:10px;
    background:var(--panel);
    min-height:200px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    text-align:center;
    padding:30px 24px;
    color:var(--text-dim);
    transition:border-color 120ms, box-shadow 120ms;
  }
  #explorer-dropzone.drag{
    border-color:var(--amber);
    box-shadow:0 0 0 1px var(--amber-dim), 0 0 24px -4px var(--amber-dim);
  }
  #explorer-dropzone .icon-glyph{
    width:48px; height:48px; margin:0 auto 12px; color:var(--text-dim);
  }
  #explorer-dropzone p{ margin:0 0 14px; font-size:14px; }

  /* --- batch bar --- */
  #batch-bar{
    width:100%;
    max-width:920px;
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:10px;
    padding:18px 20px;
    display:none;
    flex-direction:column;
    gap:14px;
  }
  #batch-bar.show{ display:flex; }
  #batch-bar input[type=number]{
    background:var(--panel-2);
    border:1px solid var(--line);
    color:var(--text);
    border-radius:6px;
    padding:5px 8px;
    font-family:var(--mono);
    font-size:12px;
  }
  #batch-bar select{
    background:var(--panel-2);
    border:1px solid var(--line);
    color:var(--text);
    border-radius:6px;
    padding:5px 6px;
    font-size:12px;
  }
  #fit-target-status{ font-family:var(--mono); }

  /* --- pdf compress --- */
  #pdf-dropzone{
    width:100%;
    max-width:920px;
    border:1.5px dashed var(--line);
    border-radius:10px;
    background:var(--panel);
    min-height:160px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    text-align:center;
    padding:30px 24px;
    color:var(--text-dim);
    transition:border-color 120ms, box-shadow 120ms;
  }
  #pdf-dropzone.drag{
    border-color:var(--amber);
    box-shadow:0 0 0 1px var(--amber-dim), 0 0 24px -4px var(--amber-dim);
  }
  #pdf-dropzone .icon-glyph{ width:48px; height:48px; margin:0 auto 12px; color:var(--text-dim); }
  #pdf-dropzone p{ margin:0 0 14px; font-size:14px; }
  .pdf-hint{ margin:10px 0 0; font-size:12px; color:var(--text-dim); text-align:center; }

  #pdf-bar{
    width:100%;
    max-width:920px;
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:10px;
    padding:18px 20px;
    display:flex;
    flex-direction:column;
    gap:14px;
  }
  #pdf-bar input[type=number]{
    background:var(--panel-2);
    border:1px solid var(--line);
    color:var(--text);
    border-radius:6px;
    padding:5px 8px;
    font-family:var(--mono);
    font-size:12px;
  }
  #pdf-bar select{
    background:var(--panel-2);
    border:1px solid var(--line);
    color:var(--text);
    border-radius:6px;
    padding:5px 6px;
    font-size:12px;
  }
  #pdf-grid{
    width:100%;
    max-width:920px;
    display:flex;
    flex-direction:column;
    gap:8px;
  }
  .pdf-item{
    display:flex;
    flex-direction:column;
    gap:6px;
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:8px;
    padding:10px 12px;
  }
  .pdf-item-top{
    display:flex;
    align-items:center;
    gap:12px;
  }
  .pdf-progress{
    height:4px;
    border-radius:2px;
    background:var(--panel-2);
    overflow:hidden;
  }
  .pdf-progress-fill{
    height:100%;
    width:0%;
    background:var(--amber);
    border-radius:2px;
    transition:width .4s ease;
  }
  .pdf-progress-label{
    font-family:var(--mono);
    font-size:11px;
    color:var(--text-dim);
    text-align:right;
  }
  .pdf-item .name{
    flex:1 1 auto;
    min-width:0;
    font-size:15px;
    color:var(--text);
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  .pdf-item .sizes{
    font-family:var(--mono);
    font-size:13px;
    color:var(--text-dim);
    flex-shrink:0;
  }
  .pdf-item .status{
    font-size:13px;
    font-family:var(--mono);
    flex-shrink:0;
    min-width:130px;
    text-align:right;
  }
  .pdf-item .status.done{ color:var(--amber); }
  .pdf-item .status.error{ color:var(--danger); }
  .pdf-item .remove-btn{
    width:20px; height:20px;
    border-radius:50%;
    background:transparent;
    border:1px solid var(--line);
    color:var(--text-dim);
    font-size:13px;
    line-height:1;
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
    padding:0;
  }
  .pdf-item .remove-btn:hover{ background:var(--danger); border-color:var(--danger); color:#fff; }

  #pdf-actions{
    width:100%;
    max-width:920px;
    display:flex;
    gap:10px;
    justify-content:center;
    flex-wrap:wrap;
  }
  #pdf-actions .spacer{ flex:1; max-width:40px; }

  /* --- explorer grid --- */
  #explorer-grid{
    width:100%;
    max-width:920px;
    display:grid;
    grid-template-columns:repeat(auto-fill, minmax(150px, 1fr));
    gap:14px;
  }
  .item-card{
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:8px;
    overflow:hidden;
    cursor:pointer;
    transition:border-color 120ms;
    position:relative;
  }
  .item-card:hover{ border-color:var(--amber-dim); }
  .item-card .thumb-wrap{
    width:100%;
    aspect-ratio:1;
    background:#0c0b08;
    display:flex;
    align-items:center;
    justify-content:center;
    overflow:hidden;
  }
  .item-card img{ max-width:100%; max-height:100%; display:block; }
  .item-card .meta{
    padding:8px 10px;
    font-size:11px;
    color:var(--text-dim);
    font-family:var(--mono);
  }
  .item-card .meta .name{
    color:var(--text);
    font-family:var(--sans);
    font-size:12px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    margin-bottom:2px;
  }
  .item-card .badge{
    position:absolute;
    top:6px; right:6px;
    background:var(--amber);
    color:#1c1304;
    font-size:10px;
    font-weight:600;
    padding:2px 6px;
    border-radius:4px;
  }
  .item-card .remove-btn{
    position:absolute;
    top:6px; left:6px;
    width:20px; height:20px;
    border-radius:50%;
    background:rgba(0,0,0,0.55);
    border:none;
    color:var(--text);
    font-size:13px;
    line-height:1;
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
  }
  .item-card .remove-btn:hover{ background:var(--danger); }

  #explorer-actions{
    width:100%;
    max-width:920px;
    display:flex;
    gap:10px;
    justify-content:center;
    flex-wrap:wrap;
  }
  #explorer-actions .spacer{ flex:1; max-width:40px; }

  /* --- item edit modal --- */
  #item-modal{
    display:none;
    position:fixed;
    inset:0;
    background:rgba(10,9,6,0.78);
    z-index:50;
    align-items:center;
    justify-content:center;
    padding:20px;
  }
  #item-modal.show{ display:flex; }
  #item-modal-panel{
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:10px;
    width:100%;
    max-width:560px;
    max-height:90vh;
    overflow-y:auto;
    padding:18px 20px;
    display:flex;
    flex-direction:column;
    gap:14px;
  }
  #item-modal-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    font-size:13px;
  }
  #item-modal-name{
    font-family:var(--mono);
    color:var(--text-dim);
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  #item-modal-stage{
    position:relative;
    background:#0c0b08;
    border-radius:8px;
    overflow:hidden;
  }
  #item-modal-stage canvas{
    display:block;
    max-width:100%;
    width:100%;
    height:auto;
  }
  #item-crop-overlay{
    position:absolute; inset:0; cursor:crosshair; display:none; touch-action:none;
  }
  #item-crop-overlay.show{ display:block; }
  #item-selection-box{
    position:absolute;
    border:1.5px solid var(--amber);
    background:rgba(227,146,43,0.14);
    display:none;
    pointer-events:none;
  }
  #item-crop-actions{
    display:none;
    gap:8px;
    justify-content:center;
  }
  #item-crop-actions.show{ display:flex; }
  #item-controls{
    display:flex;
    flex-direction:column;
    gap:12px;
  }
  #item-modal-footer{
    display:flex;
    align-items:center;
    gap:10px;
  }
  #item-modal-footer .spacer{ flex:1; }

.pdf-online-note{ margin:0 0 12px; padding:8px 12px; border-radius:8px; font-size:13px; text-align:center; color:var(--text-dim); border:1px solid var(--line); }
.pdf-online-note.offline{ color:#fff; background:#b3261e; border-color:#b3261e; font-weight:600; }
