/* ─────────────────────────────────────────────────────────────
   PDF Tools — Tech Utility theme
   Dark neutral surfaces, electric cyan accent, mono UI chrome.
   Overrides Tailwind 2.x utility classes used in index.html.
   ───────────────────────────────────────────────────────────── */

:root {
  --bg:            oklch(0.16 0.006 250);
  --bg-grid:       oklch(0.20 0.008 250);
  --surface:       oklch(0.21 0.008 250);
  --surface-2:     oklch(0.25 0.010 250);
  --surface-hover: oklch(0.27 0.012 250);

  --border:        oklch(0.30 0.012 250);
  --border-strong: oklch(0.42 0.015 250);

  --text:          oklch(0.96 0.004 250);
  --text-muted:    oklch(0.68 0.010 250);
  --text-subtle:   oklch(0.50 0.012 250);

  --accent:        oklch(0.82 0.16 200);
  --accent-hover:  oklch(0.88 0.17 200);
  --accent-fg:     oklch(0.16 0.020 250);
  --accent-soft:   oklch(0.32 0.09 200);
  --accent-glow:   oklch(0.82 0.16 200 / 0.25);

  --danger:        oklch(0.72 0.20 25);
  --danger-soft:   oklch(0.28 0.10 25);

  --radius:        6px;
  --radius-lg:     8px;

  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Monaco,
               Consolas, "Liberation Mono", monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
               Roboto, Helvetica, Arial, sans-serif;
}

[x-cloak] { display: none !important; }

/* ── base ───────────────────────────────────────────────────── */

html { background: var(--bg); }

body {
  font-family: var(--font-sans);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text);
  background:
    radial-gradient(ellipse at top, oklch(0.22 0.02 250) 0%, var(--bg) 60%),
    var(--bg);
  background-attachment: fixed;
}

::selection { background: var(--accent-soft); color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ── re-skin Tailwind utilities used in markup ──────────────── */

.bg-slate-50.text-slate-800 {
  background: transparent !important;
  color: var(--text) !important;
}

/* header */
header.bg-white {
  background: oklch(0.18 0.008 250 / 0.85) !important;
  border-bottom: 1px solid var(--border) !important;
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
}

header h1 {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 0.95rem !important;
}

.brand-subtle {
  color: var(--text-subtle);
}

.service-status {
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.70rem;
  letter-spacing: 0.04em;
}

.service-dot {
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-glow);
  display: inline-block;
  height: 6px;
  width: 6px;
}

/* logo block */
header .bg-indigo-600 {
  background: var(--surface-2) !important;
  color: var(--accent) !important;
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.70rem !important;
  letter-spacing: 0.04em;
  border-radius: var(--radius) !important;
}

/* tool cards */
button.tile.bg-white {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  position: relative;
  overflow: hidden;
  padding: 1.125rem 1.125rem 1rem !important;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}
button.tile.bg-white:hover {
  background: var(--surface-hover) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 1px var(--accent-glow), 0 10px 40px -20px var(--accent-glow) !important;
  transform: translateY(-1px);
}
button.tile.bg-white::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}
button.tile.bg-white::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, var(--accent-glow), transparent 60%);
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}
button.tile.bg-white:hover::after { opacity: 0.4; }

/* framed icon box */
.tile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--accent);
  position: relative;
  transition: border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
.tile-icon svg { width: 20px; height: 20px; }
button.tile:hover .tile-icon {
  border-color: var(--accent);
  box-shadow: 0 0 16px -2px var(--accent-glow), inset 0 0 12px -4px var(--accent-glow);
}

/* tile index — [NN] top right */
.tile-index {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-subtle);
  letter-spacing: 0.08em;
  padding-top: 4px;
}

/* tile title / desc */
button.tile .tile-title {
  font-family: var(--font-sans) !important;
  font-weight: 600 !important;
  letter-spacing: -0.01em;
  color: var(--text) !important;
  font-size: 0.95rem !important;
}
button.tile .tile-desc {
  font-family: var(--font-mono) !important;
  font-size: 0.72rem !important;
  letter-spacing: 0.01em;
  color: var(--text-muted) !important;
  text-transform: lowercase;
}

/* tile foot — thin rule + arrow */
.tile-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
}
.tile-rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}
.tile-arrow {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-subtle);
  transition: color 140ms ease, transform 140ms ease;
}
button.tile:hover .tile-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

/* tool view panel */
section.bg-white {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  position: relative;
}
section.bg-white::before {
  content: "";
  position: absolute;
  top: 0; left: 16px; right: 16px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent, var(--accent-soft) 20%, var(--accent-soft) 80%, transparent);
  opacity: 0.5;
}

/* back link */
section.bg-white .text-slate-500.hover\:text-slate-800 {
  font-family: var(--font-mono);
  font-size: 0.78rem !important;
  color: var(--text-muted) !important;
  letter-spacing: 0.02em;
}
section.bg-white .text-slate-500.hover\:text-slate-800:hover {
  color: var(--accent) !important;
}

/* tool view headings */
section.bg-white h2 {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
section.bg-white > p.text-slate-500 {
  font-family: var(--font-mono) !important;
  font-size: 0.78rem !important;
  color: var(--text-muted) !important;
}

/* dropzone */
.dropzone {
  background: var(--bg) !important;
  border: 1px dashed var(--border) !important;
  border-radius: var(--radius) !important;
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 16px 16px;
  background-position: -1px -1px;
}
.dropzone .text-slate-500 { color: var(--text-muted) !important; font-family: var(--font-mono); }
.dropzone .text-slate-500 > .text-4xl {
  font-family: var(--font-mono);
  font-size: 1.5rem !important;
  color: var(--accent);
  opacity: 0.7;
}
.dropzone .text-slate-500 > div:nth-child(2) {
  font-size: 0.85rem;
  letter-spacing: 0.01em;
}
.dropzone .text-xs { color: var(--text-subtle) !important; }

label.border-indigo-500.bg-indigo-50 {
  background: oklch(0.22 0.05 200) !important;
  border-color: var(--accent) !important;
  border-style: solid !important;
  box-shadow: inset 0 0 0 1px var(--accent-glow);
}

/* file list rows */
ul .bg-slate-50 {
  background: var(--surface-2) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius) !important;
  font-family: var(--font-mono);
  font-size: 0.78rem !important;
  color: var(--text-muted);
}
ul .bg-slate-50.bg-indigo-100 {
  background: var(--accent-soft) !important;
  border-color: var(--accent) !important;
}
ul .text-slate-400 { color: var(--text-subtle) !important; }
ul .hover\:text-red-600:hover { color: var(--danger) !important; }

/* page-preview grid tiles */
.cursor-pointer.border-slate-200,
.cursor-move.border-slate-200,
div.border-slate-200 {
  border-color: var(--border) !important;
  background: var(--surface-2);
  border-radius: var(--radius) !important;
}
.cursor-pointer.border-slate-200:hover,
.cursor-move:hover {
  border-color: var(--accent) !important;
}
.border-indigo-600.ring-indigo-300,
.border-indigo-600 {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-glow) !important;
}
.ring-indigo-300 { /* ring color via outline fallback */
  box-shadow: 0 0 0 2px var(--accent-glow) !important;
}

/* page caption strip */
.bg-slate-100 {
  background: var(--bg) !important;
  color: var(--text-muted) !important;
  font-family: var(--font-mono);
  font-size: 0.68rem !important;
  letter-spacing: 0.04em;
  border-top: 1px solid var(--border);
}

/* "selected page" check chip */
.page-check-chip {
  background: var(--accent) !important;
  color: var(--accent-fg) !important;
  font-family: var(--font-mono);
  border-radius: 4px !important;
  width: 1.25rem !important;
  height: 1.25rem !important;
  font-size: 0.70rem !important;
  box-shadow: 0 0 12px var(--accent-glow);
}

.rotation-chip {
  background: var(--accent) !important;
  color: var(--accent-fg) !important;
  font-family: var(--font-mono);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* preview / hint messages */
.text-sm.text-slate-500 { color: var(--text-muted) !important; font-family: var(--font-mono); font-size: 0.78rem !important; }
.text-xs.text-slate-500 { color: var(--text-subtle) !important; font-family: var(--font-mono); }
.text-indigo-600.hover\:underline { color: var(--accent) !important; }

/* option blocks */
label.text-sm.font-medium {
  font-family: var(--font-mono);
  font-size: 0.72rem !important;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 500;
}

/* inputs */
input[type="text"], input:not([type]), input[type="number"] {
  background: var(--bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  font-family: var(--font-mono) !important;
  font-size: 0.82rem !important;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input[type="text"]:focus, input:not([type]):focus, input[type="number"]:focus {
  outline: none;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder { color: var(--text-subtle); }

/* range sliders */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  margin-top: 0.5rem;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px;
  background: var(--accent);
  border-radius: 3px;
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--bg), 0 0 12px var(--accent-glow);
  transition: transform 100ms ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  background: var(--accent);
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

/* angle pills (rotate) */
.bg-slate-100.px-4.py-2 {
  background: var(--surface-2) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius) !important;
  font-family: var(--font-mono);
  font-size: 0.80rem !important;
  transition: all 120ms ease;
}
.bg-slate-100.px-4.py-2:hover {
  border-color: var(--border-strong);
  color: var(--text) !important;
}
.bg-indigo-600.text-white.px-4.py-2 {
  background: var(--accent) !important;
  color: var(--accent-fg) !important;
  border: 1px solid var(--accent);
  border-radius: var(--radius) !important;
  font-family: var(--font-mono);
  font-size: 0.80rem !important;
  box-shadow: 0 0 16px var(--accent-glow);
}

/* primary submit button */
button.bg-indigo-600.text-white.font-medium {
  background: var(--accent) !important;
  color: var(--accent-fg) !important;
  border-radius: var(--radius) !important;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 0.82rem !important;
  border: 1px solid var(--accent);
  box-shadow: 0 0 24px -4px var(--accent-glow);
  transition: background 120ms ease, transform 100ms ease, box-shadow 120ms ease;
}
button.bg-indigo-600.text-white.font-medium:hover:not(:disabled) {
  background: var(--accent-hover) !important;
  box-shadow: 0 0 32px -4px var(--accent-glow);
  transform: translateY(-1px);
}
button.bg-indigo-600.text-white.font-medium:active:not(:disabled) {
  transform: translateY(0);
}
button.bg-indigo-600.text-white.font-medium:disabled {
  background: var(--surface-2) !important;
  color: var(--text-subtle) !important;
  border-color: var(--border) !important;
  box-shadow: none;
}

/* error text */
.text-red-600 {
  color: var(--danger) !important;
  font-family: var(--font-mono);
  font-size: 0.78rem !important;
}

/* spinner accent */
.animate-spin { color: var(--accent-fg); }

/* ─── PDF thumbnail rotation (per-page rotate UI) ─── */

.pdf-thumb-frame {
  align-items: center;
  aspect-ratio: 3 / 4;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.pdf-thumb-image {
  display: block;
  max-height: 100%;
  max-width: 100%;
  transform-origin: center;
  transition: transform 0.15s ease;
}

.pdf-thumb-rot-90 { transform: rotate(90deg); }
.pdf-thumb-rot-180 { transform: rotate(180deg); }
.pdf-thumb-rot-270 { transform: rotate(270deg); }

/* ─── Mobile-friendly options / progress ─── */

.option-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.85rem;
}

.option-label {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  margin-bottom: 0.55rem;
  text-transform: uppercase;
}

.option-grid {
  display: grid;
  gap: 0.5rem;
}

.option-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.option-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.option-button {
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.45rem 0.5rem;
  text-align: center;
}

.option-button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  box-shadow: 0 0 16px -6px var(--accent-glow);
}

.progress-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.85rem;
}

.organize-thumb.is-deleted img {
  filter: grayscale(1);
  opacity: 0.38;
}

.organize-delete {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  display: inline-flex;
  font-family: var(--font-mono);
  height: 1.75rem;
  justify-content: center;
  position: absolute;
  right: 0.35rem;
  top: 0.35rem;
  width: 1.75rem;
}

.organize-delete.is-active {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* ─── Local PDF reader ─── */

.reader-shell {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.reader-toolbar {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.reader-zoom {
  align-items: center;
  display: inline-flex;
  gap: 0.5rem;
}

.reader-zoom button {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  display: inline-flex;
  font-family: var(--font-mono);
  height: 2rem;
  justify-content: center;
  width: 2rem;
}

.reader-pages {
  display: grid;
  gap: 1rem;
}

.reader-page {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.reader-page img {
  background: #fff;
  display: block;
  height: auto;
  width: 100%;
}

.reader-page-num {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  padding: 0.45rem 0;
  text-align: center;
}
