/* EazyExtract production stylesheet: no runtime CSS CDN required. */
:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1e293b;
  background: #f1f5f9;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, a { font: inherit; }
.page-shell {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 28px 16px; gap: 22px;
  background: radial-gradient(ellipse at top, #dbeafe 0%, #f8fafc 45%, #f1f5f9 100%);
}

.app-icon {
  display: grid; place-items: center; width: 66px; height: 66px; margin: 0 auto 20px;
  color: #2563eb; background: #dbeafe; border-radius: 20px;
}
.app-icon svg { width: 34px; height: 34px; }
.eyebrow { margin: 0 0 8px; color: #2563eb; font-size: .72rem; font-weight: 800; letter-spacing: .16em; }
h1 { margin: 0; color: #0f172a; font-size: clamp(2rem, 7vw, 2.45rem); line-height: 1.15; letter-spacing: -.045em; }
.intro { margin: 15px auto 25px; max-width: 340px; color: #64748b; font-size: .98rem; line-height: 1.65; }
.button {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 52px;
  padding: 14px 18px; border: 0; border-radius: 13px; text-decoration: none;
  font-weight: 750; cursor: pointer; transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.button:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .6; transform: none; }
.button-primary { color: white; background: #2563eb; box-shadow: 0 8px 18px rgba(37, 99, 235, .18); }
.button-primary:hover { background: #1d4ed8; }
.button-success { color: white; background: #059669; margin-bottom: 10px; }
.button-success:hover { background: #047857; }
.button-secondary { color: #334155; background: #f1f5f9; border: 1px solid #e2e8f0; }
.button-secondary:hover { background: #e2e8f0; }
.file-limit { margin: 11px 0 0; color: #94a3b8; font-size: .8rem; }
.loading-state { padding: 25px 0 4px; }
.loading-state p { margin: 10px 0 0; color: #334155; font-weight: 650; }
.loading-state .substatus { color: #94a3b8; font-size: .8rem; font-weight: 400; line-height: 1.5; }
.spinner { display: inline-block; width: 35px; height: 35px; border: 4px solid #dbeafe; border-top-color: #2563eb; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-state { padding-top: 22px; }
.success-mark { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 50%; color: #047857; background: #d1fae5; font-size: 1.5rem; font-weight: 800; }
.result-title { margin: 0 0 16px; color: #0f172a; font-weight: 750; }
.error-text { margin: 18px 0 0; padding: 12px 14px; border-radius: 10px; color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; font-size: .88rem; line-height: 1.5; text-align: left; }
.privacy-note { margin: 24px 0 0; color: #94a3b8; font-size: .77rem; }
.page-footer { color: #94a3b8; font-size: .78rem; text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
@media (max-width: 420px) {
  .app-card { padding: 30px 22px 25px; border-radius: 21px; }
  .intro { font-size: .92rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* --- Tool Navigation --- */
.nav-pills, .tool-nav { display: flex; justify-content: center; gap: 10px; margin-bottom: 24px; }
.nav-pill, .tool-btn { padding: 8px 18px; border-radius: 20px; text-decoration: none; color: #64748b; font-size: 0.9rem; font-weight: 700; background: #f1f5f9; transition: all 0.2s ease; border: 1px solid transparent; }
.nav-pill:hover, .tool-btn:hover { background: #e2e8f0; color: #334155; }
.nav-pill.active, .tool-btn.active { color: white; background: #2563eb; border-color: #2563eb; box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2); }



/* --- File Info Badge --- */
.file-info-badge { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; margin-bottom: 16px; text-align: left; }
.file-info-text { display: flex; flex-direction: column; overflow: hidden; }
.file-info-name { font-weight: 700; font-size: 0.95rem; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90%; }
.file-info-meta { font-size: 0.8rem; color: #64748b; margin-top: 2px; }
.btn-text { background: none; border: none; color: #2563eb; font-weight: 700; cursor: pointer; padding: 6px 12px; font-size: 0.9rem; border-radius: 6px; transition: background 0.15s; }
.btn-text:hover { background: #eff6ff; }

/* --- Selection Toolbar & Range Input --- */
.selection-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding: 0 4px; }
.selection-summary { font-weight: 700; color: #334155; font-size: 0.95rem; }
.toolbar-actions { display: flex; gap: 4px; align-items: center; }
.toolbar-divider { color: #cbd5e1; font-weight: bold; }
.range-container { display: flex; gap: 10px; margin-bottom: 20px; }
.range-input { flex: 1; padding: 12px 16px; border: 1px solid #cbd5e1; border-radius: 10px; font-family: inherit; font-size: 0.95rem; color: #0f172a; outline: none; transition: border-color 0.2s; }
.range-input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px #dbeafe; }
.range-apply-btn { padding: 0 20px; background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 10px; font-weight: 700; cursor: pointer; color: #475569; transition: all 0.2s; }
.range-apply-btn:hover { background: #e2e8f0; color: #0f172a; }

/* --- Visual Page Grid & Canvas Thumbnails (Large iLovePDF Style) --- */
.page-grid-container { max-height: 600px; overflow-y: auto; padding: 12px; margin-bottom: 24px; border: 1px solid #e2e8f0; border-radius: 14px; background: #f8fafc; }
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px; padding: 10px; }
.page-tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; background: white; border: 2px solid #e2e8f0; border-radius: 12px; padding: 12px; cursor: pointer; transition: all 0.15s ease; min-height: 260px; user-select: none; }
.page-tile:hover { border-color: #94a3b8; transform: translateY(-3px); box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08); }
.page-tile.selected { border-color: #2563eb; background: #eff6ff; }
.page-tile-check { position: absolute; top: 12px; right: 12px; width: 28px; height: 28px; background: #2563eb; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: bold; opacity: 0; transform: scale(0.8); transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); line-height: 1; z-index: 10; box-shadow: 0 2px 6px rgba(37,99,235,0.4); }
.page-tile.selected .page-tile-check { opacity: 1; transform: scale(1); }
.page-tile-preview { width: 100%; height: 200px; margin-bottom: 12px; display: flex; align-items: center; justify-content: center; background: #f1f5f9; border-radius: 8px; overflow: hidden; border: 1px solid #e2e8f0; }
.page-tile-preview canvas { max-width: 100%; max-height: 100%; object-fit: contain; background: white; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.page-tile-num { font-size: 0.95rem; font-weight: 700; color: #64748b; margin-top: auto; }
.page-tile.selected .page-tile-num { color: #1e40af; }


/* --- True Native Desktop Workspace (iLovePDF Style) --- */
@media (min-width: 1024px) {
  /* 1. Lock Viewport & Prevent Whole-Page Scrolling */
  body, .page-shell {
    height: 100vh;
    overflow: hidden;
  }
  .page-shell {
    padding: 24px;
    align-items: stretch;
  }
  
  /* 2. Convert App Card into Full-Screen App Window */
  .app-card {
    padding: 32px 40px; 
    display: flex;
    flex-direction: column;
    max-height: 100%;
  }
  .app-card.app-card-wide {
    width: min(100%, 1400px);
    margin: 0 auto;
  }

  /* 3. Hide large intro text in workspace mode to maximize vertical height */
  .app-card-wide .app-icon,
  .app-card-wide .eyebrow,
  .app-card-wide .intro,
  .app-card-wide .tool-nav {
    display: none !important;
  }
  .app-card-wide #app-title {
    text-align: left;
    font-size: 1.6rem;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
  }

  /* 4. Split Layout: CSS Grid mapping without changing HTML */
  .select-state {
    display: grid;
    grid-template-columns: 1fr 340px; /* Left: Grid, Right: Sidebar */
    grid-template-rows: auto auto 1fr;
    gap: 16px 40px;
    flex: 1;
    overflow: hidden; /* Contain scroll within this box */
    min-height: 0; /* Required for CSS flex/grid overflow rules */
  }
  
  /* --- LEFT COLUMN: Scrollable Page Grid --- */
  .selection-toolbar {
    grid-column: 1; grid-row: 1;
    margin-bottom: 0;
  }
  .page-grid-container {
    grid-column: 1; grid-row: 2 / span 2;
    height: 100%;
    max-height: none;
    overflow-y: auto; /* Internal scrolling restricted to the grid area only */
    margin-bottom: 0;
    background: #f8fafc;
    border-radius: 12px;
  }

  /* --- RIGHT COLUMN: Settings Sidebar --- */
  .file-info-badge {
    grid-column: 2; grid-row: 1;
    margin-bottom: 0;
    height: max-content;
  }
  .range-container {
    grid-column: 2; grid-row: 2;
    flex-direction: column; /* Stack input on top of apply button */
    margin-bottom: 0;
  }
  .range-input { margin-bottom: 12px; }
  .range-apply-btn { padding: 12px; width: 100%; }
  
  .button-stack {
    grid-column: 2; grid-row: 3;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Push action buttons strictly to bottom-right corner */
  }
}