:root{
  /* Brighter basil / sage palette */
  --bg0: #0e1713;
  --bg1: #141f19;

  --panel: rgba(255, 255, 255, 0.07);
  --panel2: rgba(255, 255, 255, 0.05);
  --card: rgba(255, 255, 255, 0.06);

  --border: rgba(120, 220, 170, 0.22);

  --text: rgba(250, 252, 251, 0.96);
  --muted: rgba(250, 252, 251, 0.78);
  --muted2: rgba(250, 252, 251, 0.62);

  /* more vivid accent */
  --accent: #48d18f;
  --accent2: rgba(72, 209, 143, 0.18);
  --danger: #ff6a6a;

  --shadow: 0 18px 44px rgba(0,0,0,0.35);
  --shadow2: 0 10px 28px rgba(0,0,0,0.28);

  --radius: 18px;
  --radius2: 14px;
  --focus: 0 0 0 3px rgba(72, 209, 143, 0.22);

  /* Background image */
  --bg-img: url("./assets/bg.jpg");

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
          "Courier New", monospace;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
html{ background: var(--bg0); }

body{
  margin:0;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.5;

  /* critical for layered background */
  position: relative;
  isolation: isolate;
}

/* ===== Background: photo + overlay (CLEAN, no duplicates) ===== */
body::before{
  content:"";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: var(--bg-img) center / cover no-repeat;

  /* lighter, cleaner */
  filter: blur(10px) saturate(1.02) brightness(1.08) contrast(1.03);
  transform: scale(1.06);
  opacity: 0.62;
}

body::after{
  content:"";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1200px 800px at 18% 10%, rgba(72,209,143,0.22), transparent 62%),
    radial-gradient(900px 650px at 85% 20%, rgba(72,209,143,0.14), transparent 65%),
    radial-gradient(900px 700px at 50% 80%, rgba(0,0,0,0.22), transparent 60%),
    linear-gradient(180deg, rgba(14,23,19,0.32), rgba(14,23,19,0.72));
}

/* Preview pages: slightly calmer background */
body.preview::before{
  opacity: 0.58;
  filter: blur(13px) saturate(0.88) brightness(0.90) contrast(1.05);
}

a{ color: inherit; text-decoration:none; }
b{ font-weight: 750; }
.muted{ color: var(--muted); margin:0; }
.micro{ color: var(--muted2); margin: 8px 0 0; min-height: 18px; }
.error{ color: var(--danger); }

.container{
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 18px;
}

/* Topbar */
.topbar{
  position: sticky;
  top:0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(18, 30, 24, 0.62);
  border-bottom: 1px solid var(--border);
}
.topbar-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding: 14px 0;
}
.brand-title{ font-weight: 860; letter-spacing: 0.2px; }
.brand-sub{ color: var(--muted2); font-size: 13px; margin-top: 2px; }

.nav{ display:flex; gap: 10px; }
.nav-link{
  color: var(--muted);
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
}
.nav-link:hover{
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.06);
  color: var(--text);
}

/* Hero */
.hero{
  display:grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 16px;
  padding: 22px 0 12px;
}
.h1{
  font-size: 30px;
  margin: 0 0 8px;
  letter-spacing: -0.25px;
}
.h2{
  font-size: 18px;
  margin: 0 0 6px;
}
.hero-badges{ display:flex; gap: 8px; flex-wrap:wrap; margin-top: 12px; }
.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 12px;
}

/* Cards */
.card{
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow2);
  margin-bottom: 16px;
}
.card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 14px;
  margin-bottom: 12px;
}

/* Meta card */
.meta-card{
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.meta-title{
  color: var(--muted2);
  font-size: 13px;
  margin-bottom: 8px;
}
.meta-pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 9px 10px;
  border-radius: 999px;
  border: 1px solid rgba(130,159,130,0.34);
  background: rgba(130,159,130,0.12);
  font-size: 14px;
  font-weight: 650;
}
.meta-hint{ color: var(--muted2); font-size: 13px; margin-top: 10px; }

/* Tools grid */
.tools{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.tool{
  text-align:left;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius2);
  padding: 14px;
  cursor:pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}
.tool:hover{
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.045);
  box-shadow: 0 0 0 2px rgba(130,159,130,0.08);
}
.tool:focus-visible{ outline: none; box-shadow: var(--focus); }

.tool-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom: 8px;
}
.tool-title{ font-weight: 860; }
.tool-sub{ color: var(--muted2); font-size: 13px; }

.chip{
  font-size: 12px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.18);
  color: var(--muted);
}

/* Selected tool highlight */
.tool.active,
body[data-selected-tool="text_to_pdf"] .tool[data-tool="text_to_pdf"],
body[data-selected-tool="pdf_to_text"] .tool[data-tool="pdf_to_text"],
body[data-selected-tool="image_to_pdf"] .tool[data-tool="image_to_pdf"],
body[data-selected-tool="pdf_to_images"] .tool[data-tool="pdf_to_images"]{
  border-color: rgba(130,159,130,0.58);
  background: linear-gradient(180deg, rgba(130,159,130,0.16), rgba(255,255,255,0.02));
  box-shadow: 0 0 0 2px rgba(130,159,130,0.10), 0 0 26px rgba(130,159,130,0.06);
}

/* Flow panel */
.flow{
  display:grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  gap: 12px;
  padding-top: 6px;
}
.flow-col{
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.14);
  border-radius: var(--radius2);
  padding: 14px;
}
.flow-title{
  font-size: 12px;
  color: var(--muted2);
  letter-spacing: 0.22px;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.flow-value{
  font-weight: 760;
  margin-bottom: 8px;
}
.flow-note{
  color: var(--muted2);
  font-size: 13px;
}

/* Inputs + button */
.label{ display:block; font-size: 14px; margin-bottom: 8px; color: var(--muted); }
.input{
  width:100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.20);
  color: var(--text);
}
.input:focus-visible{
  outline:none;
  box-shadow: var(--focus);
  border-color: rgba(130,159,130,0.40);
}

.btn{
  width:100%;
  border: 1px solid rgba(72,209,143,0.48);
  background: linear-gradient(180deg, rgba(72,209,143,0.20), rgba(255,255,255,0.03));
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 760;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.btn:hover{
  background: linear-gradient(180deg, rgba(72,209,143,0.26), rgba(255,255,255,0.05));
  border-color: rgba(72,209,143,0.72);
  transform: translateY(-1px);
}
.btn:disabled{ opacity: 0.6; cursor: not-allowed; transform: none; }

/* Progress */
.progress{
  margin-top: 10px;
  width:100%;
  height: 10px;
  border-radius: 999px;
  overflow:hidden;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.18);
}
.progress-value{
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(130,159,130,0.92), rgba(255,255,255,0.22));
  transition: width 220ms ease;
}

/* About */
.about-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
}
.about-item{
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius2);
  padding: 14px;
}
.about-title{ font-weight: 860; margin-bottom: 8px; }
.about-text{ color: var(--muted); margin: 0; }
.about-list{ margin: 0; padding-left: 18px; color: var(--muted); }
.about-list li{ margin: 6px 0; }

/* Footer */
.footer{
  padding: 14px 0 24px;
  color: var(--muted2);
  font-size: 13px;
}

/* ===== Preview pages (after conversion) =====
   Add class="preview" on <body> in preview templates,
   and wrap controls with <div class="preview-toolbar"> ... </div> */
body.preview .container{ max-width: 1240px; }

body.preview .preview-toolbar{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:10px;
  padding: 10px;
  margin: 12px 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  background: var(--panel);
  box-shadow: var(--shadow2);
  backdrop-filter: blur(10px);
}

body.preview .preview-toolbar .btn{
  width:auto;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
}

body.preview .preview-toolbar .btn.ghost{
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
}

body.preview .preview-toolbar .sep{
  width:1px;
  height: 26px;
  background: rgba(255,255,255,0.10);
  margin: 0 2px;
}

body.preview canvas,
body.preview .preview-surface{
  display:block;
  max-width: 100%;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

/* preview: buttons must NOT be full width */
body.preview .btn{
  width:auto;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
}

body.preview .preview-toolbar{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:10px;
  padding: 10px;
  margin: 12px 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  background: var(--panel);
  box-shadow: var(--shadow2);
  backdrop-filter: blur(10px);
}

body.preview .btn.ghost{
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
}

.pill{
  display:inline-flex;
  align-items:center;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.18);
  color: var(--muted);
  font-size: 13px;
}

.spacer{ flex: 1; }


/* Responsive */
@media (max-width: 980px){
  .hero{ grid-template-columns: 1fr; }
  .tools{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  .flow{ grid-template-columns: 1fr; }
  .about-grid{ grid-template-columns: 1fr; }
}
@media (max-width: 520px){
  .tools{ grid-template-columns: 1fr; }
}
/* ===== File input: pretty button ===== */
.file{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.20);
}

.file-input{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border:0;
}

.file-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(130,159,130,0.55);
  background: rgba(130,159,130,0.16);
  color: var(--text);
  font-weight: 760;
  cursor: pointer;
  user-select: none;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.file-btn:hover{
  background: rgba(130,159,130,0.22);
  border-color: rgba(130,159,130,0.72);
  transform: translateY(-1px);
}

.file-btn:active{ transform: translateY(0); }

.file-input:focus-visible + .file-btn{
  outline: none;
  box-shadow: var(--focus);
}

.file-name{
  color: var(--muted);
  font-size: 13px;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}


/* --- Result/Preview pages: actions buttons layout --- */
body.result-body .result-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  flex-wrap:wrap;
}

body.result-body .result-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:flex-end;
}

body.result-body .result-actions .btn,
body.result-body .result-actions a.btn,
body.result-body .result-actions button.btn{
  width:auto;
  min-width:140px;
  padding:8px 12px;
  border-radius:10px;
  font-size:13px;
}

@media (max-width: 720px){
  body.result-body .result-actions{ justify-content:flex-start; }
  body.result-body .result-actions .btn{ min-width:0; }
}

/* --- Preview images: smaller centered "paper" --- */
body.result-body .gallery{
  display:flex;
  justify-content:center;
}

/* Image preview: medium size, centered */
body.result-body .gallery .grid{
  max-width: 980px;
}

body.result-body .gallery .thumb img{
  max-width: 720px;
  max-height: 520px;
}

body.result-body .gallery .thumb img{
  width:auto;
  max-width:520px;
  max-height:380px;
  object-fit:contain;
}

/* --- Text preview: centered "paper" (single, with scroll) --- */
body.result-body.preview .viewer{
  display:flex;
  justify-content:center;
}

body.result-body.preview #textBox.text-box{
  width:auto;
  max-width:600px;
  max-height:500px;
  margin:16px auto 28px;
  padding:16px 18px;

  background:#fff;
  color:#111;
  border-radius:10px;
  border:1px solid rgba(0,0,0,0.12);
  box-shadow:0 18px 44px rgba(0,0,0,0.28);

  font-family: var(--mono);
  font-size:13px;
  line-height:1.55;
  white-space:pre-wrap;
  overflow:auto;
}

/* ===== File input: pretty button (RESTORED) ===== */
.file{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.20);
}

.file-input{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border:0;
}

.file-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(72,209,143,0.55);
  background: rgba(72,209,143,0.16);
  color: var(--text);
  font-weight: 760;
  cursor: pointer;
  user-select: none;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.file-btn:hover{
  background: rgba(72,209,143,0.22);
  border-color: rgba(72,209,143,0.72);
  transform: translateY(-1px);
}

.file-btn:active{ transform: translateY(0); }

/* если между input и label вдруг есть элементы — ~ тоже поймает */
.file-input:focus-visible + .file-btn,
.file-input:focus-visible ~ .file-btn{
  outline: none;
  box-shadow: var(--focus);
}

.file-name{
  color: var(--muted);
  font-size: 13px;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

