/* ==========================================================================
   PHOSPHOR PDF LAB — Dual-Theme Stylesheet
   Theme 1: CRT '96 (Project Phosphor 1996 Workstation)
   Theme 2: OFFICE (Clean Daylight Corporate Paper Workstation)
   ========================================================================== */

:root,
[data-theme="crt"] {
  --font-ui: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Consolas", "Cascadia Mono", "Courier New", monospace;

  --bg-app: #0b1116;
  --bg-panel: #131c24;
  --bg-panel-alt: #18232d;
  --bg-surface: #0e161d;
  --bg-input: #0a1015;
  --bg-canvas: #070b0f;

  --border: #273847;
  --border-hi: #3a5266;
  --border-lo: #070b0e;

  --text-main: #e6f2ec;
  --text-muted: #8ea6b5;
  --text-dim: #627a8a;

  --accent: #39ff88;
  --accent-bg: rgba(57, 255, 136, 0.12);
  --accent-text: #06180d;
  --accent-2: #ffb84d;
  --danger: #ff5c6c;
  --danger-bg: rgba(255, 92, 108, 0.14);
  --info: #4cc9f0;

  --bevel-btn: inset 1px 1px 0 rgba(255, 255, 255, 0.14), inset -1px -1px 0 rgba(0, 0, 0, 0.45);
  --bevel-inset: inset 1px 1px 0 rgba(0, 0, 0, 0.55), inset -1px -1px 0 rgba(255, 255, 255, 0.08);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.45);
  --radius: 4px;
  --radius-lg: 6px;
  --scanline-opacity: 0.08;
}

[data-theme="office"] {
  --font-ui: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Consolas", "SFMono-Regular", monospace;

  --bg-app: #eef2f6;
  --bg-panel: #ffffff;
  --bg-panel-alt: #f6f8fb;
  --bg-surface: #f8fafc;
  --bg-input: #ffffff;
  --bg-canvas: #dde4ec;

  --border: #d0d9e4;
  --border-hi: #b5c4d6;
  --border-lo: #e2e8f0;

  --text-main: #182433;
  --text-muted: #526378;
  --text-dim: #79899c;

  --accent: #1d4ed8;
  --accent-bg: rgba(29, 78, 216, 0.09);
  --accent-text: #ffffff;
  --accent-2: #0f766e;
  --danger: #c81e1e;
  --danger-bg: rgba(200, 30, 30, 0.08);
  --info: #0369a1;

  --bevel-btn: 0 1px 2px rgba(15, 23, 42, 0.06);
  --bevel-inset: inset 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-card: 0 3px 12px rgba(15, 23, 42, 0.08);
  --radius: 6px;
  --radius-lg: 10px;
  --scanline-opacity: 0;
}

/* THEME 3: TURBO '96 — FULL HARDCORE 1996 PHOSPHOR MAINFRAME TERMINAL */
[data-theme="turbo"] {
  --font-ui: "Consolas", "Cascadia Mono", "Courier New", monospace;
  --font-mono: "Consolas", "Cascadia Mono", "Courier New", monospace;

  --bg-app: #020804;
  --bg-panel: #041208;
  --bg-panel-alt: #061b0c;
  --bg-surface: #030e06;
  --bg-input: #010602;
  --bg-canvas: #010402;

  --border: #0e6b32;
  --border-hi: #00ff66;
  --border-lo: #010502;

  --text-main: #7affaa;
  --text-muted: #35c46c;
  --text-dim: #1d7a42;

  --accent: #00ff66;
  --accent-bg: rgba(0, 255, 102, 0.14);
  --accent-text: #011407;
  --accent-2: #ffb000;
  --danger: #ff3355;
  --danger-bg: rgba(255, 51, 85, 0.16);
  --info: #00f0ff;

  --bevel-btn: inset 2px 2px 0 rgba(0, 255, 102, 0.35), inset -2px -2px 0 rgba(0, 20, 8, 0.9), 0 0 8px rgba(0, 255, 102, 0.15);
  --bevel-inset: inset 2px 2px 0 rgba(0, 0, 0, 0.85), inset -1px -1px 0 rgba(0, 255, 102, 0.25);
  --shadow-card: 0 0 18px rgba(0, 255, 102, 0.14), inset 0 0 0 1px rgba(0, 255, 102, 0.18);
  --radius: 0px;
  --radius-lg: 0px;
  --scanline-opacity: 0.24;
}

[data-theme="turbo"] body,
[data-theme="turbo"] .brand-title,
[data-theme="turbo"] .lcd-val,
[data-theme="turbo"] .vault-title,
[data-theme="turbo"] .tab-name {
  text-shadow: 0 0 6px rgba(0, 255, 102, 0.45);
}

[data-theme="turbo"] .topbar,
[data-theme="turbo"] .statusbar {
  border-color: #00ff66;
  box-shadow: 0 0 14px rgba(0, 255, 102, 0.18);
}

[data-theme="turbo"] .workbench {
  background-color: #020804;
  background-image:
    linear-gradient(rgba(0, 255, 102, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 102, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
}

[data-theme="turbo"] .crt-scanlines::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, transparent 62%, rgba(0, 0, 0, 0.62) 100%);
}

[data-theme="turbo"] .brand-mark {
  background: #00ff66;
  color: #011407;
  box-shadow: 0 0 12px rgba(0, 255, 102, 0.75);
}

[data-theme="turbo"] .proof-pill {
  border-style: double;
  border-width: 3px;
  box-shadow: 0 0 12px rgba(0, 255, 102, 0.28);
}

[data-theme="turbo"] .vault-card,
[data-theme="turbo"] .card-box,
[data-theme="turbo"] .modal-window {
  border: 2px solid #00ff66;
}

[data-theme="turbo"] .page-card.selected {
  box-shadow: 0 0 16px rgba(0, 255, 102, 0.45);
}

[data-theme="turbo"] .export-btn,
[data-theme="turbo"] .cta-btn.primary {
  text-transform: uppercase;
  letter-spacing: 0.7px;
  box-shadow: 0 0 14px rgba(0, 255, 102, 0.38);
}

[data-theme="turbo"] .orig-num {
  color: #ffb000;
  text-shadow: 0 0 5px rgba(255, 176, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 13.5px;
  overflow: hidden;
}

/* Subtle CRT scanlines — automatically hidden in Office mode */
.crt-scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: var(--scanline-opacity);
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.55) 3px,
    transparent 4px
  );
  transition: opacity 0.2s ease;
}

body.no-scanlines .crt-scanlines {
  opacity: 0 !important;
}

/* ==========================================================================
   TOP BAR
   ========================================================================== */
.topbar {
  height: 54px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  flex-shrink: 0;
  user-select: none;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.5px;
  display: grid;
  place-items: center;
  box-shadow: var(--bevel-btn);
  flex-shrink: 0;
}

.brand-title {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.ver-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--border);
}

.brand-sub {
  font-size: 10px;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.telemetry-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
}

.proof-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.1s ease, filter 0.15s ease;
}

[data-theme="office"] .proof-pill {
  background: #ecfdf5;
  border-color: #10b981;
  color: #047857;
}

.proof-pill:hover {
  filter: brightness(1.08);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

.lcd-strip {
  display: flex;
  gap: 5px;
}

.lcd-cell {
  background: var(--bg-input);
  border: 1px solid var(--border);
  box-shadow: var(--bevel-inset);
  border-radius: var(--radius);
  padding: 3px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
}

.lcd-lbl {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.lcd-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

[data-theme="office"] .lcd-val {
  color: var(--text-main);
}

.controls-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* THEME SWITCH PILL */
.theme-switch {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}

.theme-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: calc(var(--radius) - 1px);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.theme-btn:hover {
  color: var(--text-main);
}

.theme-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--bevel-btn);
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-panel-alt);
  color: var(--text-main);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  box-shadow: var(--bevel-btn);
}

.icon-btn:hover {
  border-color: var(--border-hi);
}

.icon-btn.muted {
  opacity: 0.55;
}

[data-theme="office"] .icon-btn.muted {
  opacity: 0.72;
  background: var(--bg-panel-alt);
}

[data-theme="office"] #btnScanlines {
  display: none;
}

.hdr-btn {
  height: 31px;
  padding: 0 11px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--bevel-btn);
}

.hdr-btn.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.hdr-btn.secondary {
  background: var(--bg-panel-alt);
  color: var(--text-main);
}

.hdr-btn:hover {
  filter: brightness(1.07);
}

/* ==========================================================================
   MAIN SHELL & SIDEBAR
   ========================================================================== */
.app-shell {
  display: flex;
  height: calc(100vh - 54px - 44px);
  overflow: hidden;
}

.sidebar {
  width: 238px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 10px 8px;
  gap: 10px;
  overflow-y: auto;
  flex-shrink: 0;
}

.nav-section-lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  padding: 2px 6px 5px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tool-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tool-tab {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 8px 9px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.tool-tab:hover {
  background: var(--bg-panel-alt);
  border-color: var(--border);
}

.tool-tab.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  box-shadow: var(--bevel-btn);
}

.tab-ico {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.tab-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.tab-name {
  font-weight: 700;
  font-size: 12.5px;
  line-height: 1.2;
}

.tool-tab.active .tab-name {
  color: var(--accent);
}

.tab-desc {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  background: var(--accent);
  color: var(--accent-text);
  padding: 1px 6px;
  border-radius: 999px;
}

/* LOADED SOURCE FILES */
.loaded-files-panel {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.source-hint {
  font-size: 10px;
  color: var(--text-dim);
  padding: 0 6px 5px;
}

.source-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 140px;
  overflow-y: auto;
}

.source-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: var(--radius);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 11px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  color: var(--text-main);
  transition: border-color 0.12s ease, opacity 0.12s ease;
}

.source-item:hover {
  border-color: var(--accent);
}

.source-item.inactive {
  opacity: 0.48;
  border-style: dashed;
}

.source-item.inactive .source-name {
  text-decoration: line-through;
}

.source-toggle {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 900;
  color: var(--accent);
  width: 13px;
  text-align: center;
  flex-shrink: 0;
}

.source-item.inactive .source-toggle {
  color: var(--text-dim);
}

.source-chip {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.source-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-pg {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.link-mini {
  background: none;
  border: none;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  color: var(--text-muted);
}

.link-mini.danger {
  color: var(--danger);
}

.link-mini:hover {
  text-decoration: underline;
}

.help-bay {
  margin-top: auto;
}

.help-btn {
  margin-bottom: 0;
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.feedback-bay {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 9px;
  font-size: 11px;
}

.inline-help-dot {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1px solid var(--border-hi);
  background: var(--bg-panel);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  padding: 0;
  margin-left: 2px;
}

.inline-help-dot:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.help-guide-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.help-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 13px;
}

.help-section h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--accent);
}

[data-theme="office"] .help-section h3 {
  color: #1e3a5f;
}

.help-section ul {
  margin: 4px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.help-section p {
  font-size: 12.5px;
}

.help-section code {
  background: var(--bg-input);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--font-mono);
  color: var(--text-main);
  font-size: 11.5px;
}

/* ZERO-TRACKER PROJECT PHOSPHOR DIRECT BAY */
.direct-bay {
  background: var(--bg-surface);
  border: 1px dashed var(--border-hi);
  border-radius: var(--radius);
  padding: 9px;
  font-size: 11px;
}

.bay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.bay-tag {
  background: var(--accent-bg);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 9px;
}

[data-theme="office"] .bay-tag {
  background: #ecfdf5;
  color: #047857;
}

.bay-copy {
  margin: 0 0 7px;
  color: var(--text-muted);
  line-height: 1.35;
}

.bay-btn {
  width: 100%;
  padding: 5px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border-hi);
  background: var(--bg-panel-alt);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 7px;
}

.bay-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.sister-links {
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-dim);
}

.sister-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.sister-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ==========================================================================
   MAIN WORKBENCH & EMPTY VAULT
   ========================================================================== */
.workbench {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-app);
}

.drop-overlay {
  position: absolute;
  inset: 10px;
  z-index: 60;
  background: rgba(10, 18, 24, 0.86);
  border: 3px dashed var(--accent);
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
}

[data-theme="office"] .drop-overlay {
  background: rgba(255, 255, 255, 0.92);
}

.drop-overlay-box {
  text-align: center;
}

.drop-ico {
  font-size: 46px;
  margin-bottom: 8px;
}

.drop-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
}

.drop-sub {
  color: var(--text-muted);
  margin-top: 4px;
}

.empty-stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
}

.vault-card {
  max-width: 640px;
  width: 100%;
  background: var(--bg-panel);
  border: 2px dashed var(--border-hi);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  text-align: center;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.vault-card:hover {
  border-color: var(--accent);
}

.vault-icon {
  font-size: 42px;
  margin-bottom: 10px;
}

.vault-title {
  margin: 0 0 10px;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.vault-sub {
  margin: 0 auto 22px;
  max-width: 500px;
  color: var(--text-muted);
  line-height: 1.5;
  font-size: 14px;
}

.vault-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.cta-btn {
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-hi);
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--bevel-btn);
  transition: filter 0.12s ease, transform 0.08s ease;
}

.cta-btn.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.cta-btn.secondary {
  background: var(--bg-panel-alt);
  color: var(--text-main);
}

.cta-btn.full {
  width: 100%;
}

.cta-btn:hover:not(:disabled) {
  filter: brightness(1.07);
}

.cta-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.vault-pills {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.v-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.vault-theme-hint {
  font-size: 12px;
  color: var(--text-dim);
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   TOOL VIEWS & TOOLBARS
   ========================================================================== */
.tool-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tool-view[hidden],
.empty-stage[hidden],
.drop-overlay[hidden],
.modal-backdrop[hidden],
.toast[hidden] {
  display: none !important;
}

.view-toolbar {
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border);
  padding: 7px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.tb-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.view-toolbar .check-label {
  margin-right: 8px;
}

.tb-sep {
  width: 1px;
  height: 18px;
  background: var(--border-hi);
  margin: 0 3px;
}

.tb-btn {
  height: 28px;
  padding: 0 9px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--bevel-btn);
}

.tb-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.tb-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.tb-btn.accent {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.tb-btn.danger {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-bg);
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

.mini-input, .mini-select {
  height: 28px;
  padding: 0 7px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 12px;
}

.mini-input {
  width: 96px;
}

.hint-strip {
  padding: 5px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.hint-strip kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--bg-panel);
  border: 1px solid var(--border-hi);
  color: var(--text-main);
}

.hint-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.zoom-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.zoom-step-btn {
  width: 22px;
  height: 22px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-main);
  font-weight: 800;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.zoom-step-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.zoom-slider {
  width: 88px;
  accent-color: var(--accent);
  cursor: pointer;
}

.zoom-pct {
  font-family: var(--font-mono);
  font-size: 11px;
  min-width: 36px;
  text-align: right;
  color: var(--text-main);
}

/* ==========================================================================
   ORGANIZE THUMBNAIL GRID & DESKTOP MARQUEE BOX SELECT
   ========================================================================== */
.thumb-grid-wrap {
  flex: 1;
  position: relative;
  overflow-y: auto;
  user-select: none;
}

.thumb-grid {
  --card-min: 180px;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--card-min));
  gap: 14px;
  align-content: start;
  min-height: 100%;
}

.marquee-box {
  position: absolute;
  pointer-events: none;
  z-index: 40;
  border: 1.5px solid var(--accent);
  background: var(--accent-bg);
  border-radius: 2px;
}

[data-theme="office"] .marquee-box {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.14);
}

.page-card {
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  cursor: grab;
  position: relative;
  box-shadow: var(--shadow-card);
  transition: border-color 0.12s ease, transform 0.12s ease;
  user-select: none;
}

.page-card:hover {
  border-color: var(--border-hi);
}

.page-card.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.page-card.dragging {
  opacity: 0.4;
}

.page-card.drag-over {
  border-color: var(--accent-2);
  transform: scale(1.02);
}

.page-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.page-num-pill {
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
}

.orig-num {
  font-weight: 600;
  font-size: 10px;
  color: var(--accent-2);
  margin-left: 3px;
}

[data-theme="office"] .orig-num {
  color: #0369a1;
}

.page-badges {
  display: flex;
  gap: 3px;
  align-items: center;
}

.mini-tag {
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--accent-2);
}

.thumb-frame {
  aspect-ratio: 8.5 / 11;
  background: var(--bg-canvas);
  border-radius: 3px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}

.thumb-frame img,
.thumb-frame canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
  transition: transform 0.15s ease;
}

.page-card-actions {
  display: flex;
  justify-content: space-between;
  gap: 3px;
}

.card-act {
  flex: 1;
  height: 24px;
  border: 1px solid var(--border);
  background: var(--bg-panel-alt);
  color: var(--text-main);
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  display: grid;
  place-items: center;
}

.card-act:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.card-act:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.card-act.del:hover:not(:disabled) {
  border-color: var(--danger);
  color: var(--danger);
}

/* ==========================================================================
   INTERACTIVE CANVAS STAGE (REDACT & SIGN)
   ========================================================================== */
.security-callout {
  padding: 8px 14px;
  background: var(--accent-bg);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  line-height: 1.4;
  flex-shrink: 0;
}

[data-theme="office"] .security-callout {
  background: #eff6ff;
  color: #1e3a5f;
}

.verify-result {
  display: inline-block;
  margin-left: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
}

[data-theme="office"] .verify-result {
  color: #047857;
}

.page-indicator {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  min-width: 82px;
  text-align: center;
}

.stage-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.mini-page-rail {
  width: 112px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.rail-item {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  background: var(--bg-surface);
  cursor: pointer;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.rail-item.active {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.rail-item img {
  width: 100%;
  display: block;
  background: #fff;
  border-radius: 2px;
  margin-bottom: 3px;
}

.canvas-stage-wrap {
  flex: 1;
  background: var(--bg-canvas);
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 18px;
}

.canvas-holder {
  position: relative;
  display: inline-block;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  background: #fff;
  line-height: 0;
  user-select: none;
}

.canvas-holder canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.overlay-layer {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

#signOverlayLayer {
  cursor: default;
}

#signOverlayLayer.placing {
  cursor: copy;
}

.redact-box {
  position: absolute;
  background: #000000;
  border: 2px solid #ff4757;
  box-sizing: border-box;
}

.redact-box.draft {
  background: rgba(0, 0, 0, 0.65);
  border: 2px dashed #ff4757;
}

.redact-del {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid #fff;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
  padding: 0;
}

/* PLACED SIGNATURE / STAMP ITEM */
.placed-stamp {
  position: absolute;
  border: 1.5px dashed var(--accent);
  cursor: move;
  user-select: none;
  box-sizing: border-box;
}

.placed-stamp img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.placed-stamp .redact-del {
  opacity: 0.9;
}

/* ==========================================================================
   SIGN STUDIO
   ========================================================================== */
.sign-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.sign-studio {
  width: 312px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.studio-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--bg-input);
  padding: 3px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.studio-tabs.four-col {
  grid-template-columns: repeat(4, 1fr);
}

.studio-tabs.four-col .studio-tab {
  font-size: 11px;
  padding: 6px 2px;
}

.sig-img-preview {
  min-height: 76px;
  max-height: 120px;
  border: 1px dashed var(--border-hi);
  border-radius: var(--radius);
  background: repeating-conic-gradient(#e5e7eb 0% 25%, #ffffff 0% 50%) 50% / 14px 14px;
  display: grid;
  place-items: center;
  padding: 8px;
  overflow: hidden;
}

.sig-img-preview img {
  max-width: 100%;
  max-height: 102px;
  object-fit: contain;
}

.sign-page-actions {
  display: flex;
  gap: 6px;
  margin: 8px 0 6px;
}

.sign-page-actions .cta-btn {
  flex: 1;
  padding: 7px 10px;
  font-size: 12px;
}

.sign-page-actions .tb-btn {
  height: auto;
  padding: 7px 9px;
}

.placed-stamp.locked {
  border-style: solid;
  border-color: rgba(16, 185, 129, 0.55);
  cursor: default;
}

.wm-preview-frame {
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  display: flex;
  justify-content: center;
}

#scrubPreviewCanvas {
  max-width: 240px;
  max-height: 300px;
  width: auto;
  height: auto;
  background: #fff;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}

.studio-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
  padding: 6px 4px;
  border-radius: 3px;
  cursor: pointer;
}

.studio-tab.active {
  background: var(--accent);
  color: var(--accent-text);
}

.studio-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.studio-pane[hidden] {
  display: none !important;
}

.sig-pad-wrap {
  background: #ffffff;
  border: 2px inset var(--border-hi);
  border-radius: var(--radius);
  overflow: hidden;
  line-height: 0;
}

#sigPad {
  width: 100%;
  height: 115px;
  cursor: crosshair;
  touch-action: none;
}

.studio-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ink-swatches {
  display: flex;
  gap: 6px;
}

.ink-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}

.ink-dot.active {
  border-color: var(--accent);
  transform: scale(1.12);
}

.typed-preview {
  background: #ffffff;
  color: #111827;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 68px;
  display: grid;
  place-items: center;
  padding: 8px;
  overflow: hidden;
}

.stamp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.stamp-preset {
  padding: 8px 6px;
  border-radius: var(--radius);
  border: 2px solid currentColor;
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.6px;
  cursor: pointer;
}

.stamp-preset.green { color: #16a34a; }
.stamp-preset.red { color: #dc2626; }
.stamp-preset.blue { color: #2563eb; }
.stamp-preset.amber { color: #d97706; }
.stamp-preset.slate { color: #64748b; }
.stamp-preset.teal { color: #0d9488; }

.stamp-preset:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.studio-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.status-chip {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

/* ==========================================================================
   COMPRESS, CONVERT & SCRUB PANELS
   ========================================================================== */
.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

.section-head h2 {
  margin: 0 0 4px;
  font-size: 19px;
}

.section-head p {
  margin: 0;
  color: var(--text-muted);
}

.preset-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.preset-card {
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-card);
}

.preset-card input {
  display: none;
}

.preset-card.active {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.preset-title {
  font-weight: 800;
  font-size: 14px;
}

.preset-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.preset-meta {
  margin-top: auto;
  padding-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
}

.card-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-box h3 {
  margin: 0;
  font-size: 15.5px;
}

.card-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.two-col-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.form-grid.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.field-lbl {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.text-input {
  width: 100%;
  padding: 7px 9px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 13px;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 12.5px;
}

.range-input {
  width: 100%;
  accent-color: var(--accent);
}

.tiny-note {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.4;
}

.sub-block {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

.compress-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.compress-meter {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.meter-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.meter-lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

.meter-num {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 800;
}

.meter-num.accent {
  color: var(--info);
}

.meter-num.good {
  color: var(--accent);
}

.meter-arrow {
  font-size: 22px;
  color: var(--text-dim);
}

.meta-status {
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent-2);
}

.export-preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.img-dl-card {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 6px;
  width: 112px;
  text-align: center;
  font-size: 11px;
}

.img-dl-card img {
  width: 100%;
  height: 118px;
  object-fit: contain;
  background: #fff;
  margin-bottom: 5px;
  border-radius: 2px;
}

.img-dl-card a {
  display: block;
  padding: 3px;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 3px;
  font-weight: 700;
  text-decoration: none;
}

/* ==========================================================================
   BOTTOM STATUS & EXPORT BAR
   ========================================================================== */
.statusbar {
  height: 44px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 10px;
  flex-shrink: 0;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.status-led.busy {
  background: var(--accent-2);
  animation: blinkLed 0.6s infinite alternate;
}

@keyframes blinkLed {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

.status-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.export-name-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.export-lbl {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-dim);
}

.export-input {
  height: 30px;
  width: 210px;
  padding: 0 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 12px;
}

.export-btn {
  height: 32px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--bevel-btn);
  white-space: nowrap;
}

.export-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.export-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

/* ==========================================================================
   MODALS & TOAST
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-window {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  background: var(--bg-panel);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-window.wide {
  max-width: 820px;
}

.modal-titlebar {
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
}

.modal-close {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-main);
  width: 24px;
  height: 24px;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  line-height: 1.5;
}

.modal-body h3 {
  margin: 12px 0 4px;
  font-size: 14.5px;
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body p {
  margin: 0 0 8px;
  color: var(--text-muted);
}

.modal-body.center-scroll {
  display: flex;
  justify-content: center;
  background: var(--bg-canvas);
}

#zoomCanvas {
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

.proof-list {
  margin: 10px 0 16px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-muted);
}

.proof-list code {
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  color: var(--accent);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.toast {
  position: fixed;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  color: var(--text-main);
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

/* ==========================================================================
   RESPONSIVE FIT (1280px & smaller)
   ========================================================================== */
@media (max-width: 1380px) {
  .brand-sub { display: none; }
}

@media (max-width: 1160px) {
  .lcd-strip { display: none; }
}

@media (max-width: 960px) {
  .proof-pill { display: none; }
  .preset-cards,
  .two-col-cards {
    grid-template-columns: 1fr;
  }
  .sidebar {
    width: 195px;
  }
}
