/* ============================================================
   PNG → PDF Studio — stylesheet
   No frameworks. Dark, full-screen, responsive.
   ============================================================ */

:root {
  --bg: #0a0e1a;
  --panel: rgba(255, 255, 255, .035);
  --panel-2: rgba(255, 255, 255, .06);
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .14);
  --text: #e8ecf6;
  --muted: #93a0b8;
  --faint: #64748b;
  --cyan: #22d3ee;
  --violet: #a855f7;
  --indigo: #6366f1;
  --grad: linear-gradient(135deg, #22d3ee 0%, #6366f1 55%, #a855f7 100%);
  --danger: #f87171;
  --ok: #34d399;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; }
[hidden], .hidden { display: none !important; }
::selection { background: rgba(99, 102, 241, .45); }

:focus-visible { outline: 2px solid rgba(34, 211, 238, .75); outline-offset: 2px; }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .22); border: 2px solid transparent; background-clip: content-box; }

/* ============================================================
   APP SHELL — full screen
   ============================================================ */
.app {
  width: 100%;
  height: 100vh;
  min-height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(34, 211, 238, .10), transparent 60%),
    radial-gradient(900px 600px at 100% 110%, rgba(168, 85, 247, .12), transparent 60%),
    radial-gradient(700px 500px at 85% 20%, rgba(99, 102, 241, .08), transparent 60%),
    var(--bg);
}
@supports (height: 100dvh) { .app { height: 100dvh; } }

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 26, .72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { flex: 0 0 auto; filter: drop-shadow(0 4px 14px rgba(99, 102, 241, .45)); }
.brand-name { font-size: 15.5px; font-weight: 800; letter-spacing: .01em; white-space: nowrap; }
.brand-name .arrow { color: var(--muted); font-weight: 400; padding: 0 2px; }
.brand-name .grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-sub { font-size: 11.5px; color: var(--faint); margin-top: 1px; white-space: nowrap; }
.spacer { flex: 1; }

.stats {
  font-size: 12.5px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 7px 13px;
  border-radius: 99px;
  white-space: nowrap;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s, filter .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, .10); border-color: rgba(255, 255, 255, .22); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--grad);
  border: none;
  color: #fff;
  box-shadow: 0 4px 18px rgba(99, 102, 241, .35);
}
.btn.primary:hover { filter: brightness(1.12); }
.btn.primary:disabled {
  opacity: .45;
  cursor: not-allowed;
  filter: grayscale(.35);
  transform: none;
  box-shadow: none;
}
.btn.small { padding: 7px 12px; font-size: 12px; border-radius: 9px; }
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .12); }

/* ============================================================
   WORKSPACE
   ============================================================ */
.workspace { flex: 1; display: flex; min-height: 0; }

.stage {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 20px;
  position: relative;
  display: flex;
  flex-direction: column;
}
.stage.drag-over::after {
  content: "Release to add your PNG files";
  position: fixed;
  inset: 70px 20px 20px 322px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 26, .72);
  border: 3px dashed var(--cyan);
  border-radius: 20px;
  z-index: 30;
  pointer-events: none;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  backdrop-filter: blur(3px);
}
@media (max-width: 1060px) { .stage.drag-over::after { inset: 70px 12px 12px 12px; } }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: 302px;
  flex: 0 0 auto;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 18px 16px 26px;
  background: rgba(13, 17, 30, .55);
}
.side-section { margin-bottom: 24px; }
.side-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .11em;
  color: var(--muted);
  margin: 0 0 13px;
}
.side-section h3::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--grad); flex: 0 0 auto; }

/* ---------- form fields ---------- */
.field { display: block; margin-bottom: 14px; min-width: 0; }
.field > span {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 6px;
}
.field > span b { color: var(--cyan); font-size: 11.5px; }
.field select,
.field input[type="text"],
.field input[type="number"] {
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color .15s, background .15s;
}
.field select { appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%2393a0b8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.field select:hover, .field input[type="text"]:hover, .field input[type="number"]:hover { border-color: rgba(255, 255, 255, .24); }
.field select:focus, .field input:focus { border-color: var(--cyan); background: rgba(255, 255, 255, .07); }
.field select option { background: #141b31; color: var(--text); }
.field input[type="number"] { -moz-appearance: textfield; }
.field input[type="number"]::-webkit-inner-spin-button,
.field input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.field input[type="range"] { width: 100%; accent-color: var(--indigo); cursor: pointer; }

.check { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--indigo); cursor: pointer; flex: 0 0 auto; }

/* ---------- segmented control ---------- */
.seg {
  display: flex;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: 11px;
  gap: 2px;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  flex: 1;
  text-align: center;
  padding: 7px 4px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s;
}
.seg label:hover { color: var(--text); }
.seg input:checked + label { background: var(--grad); color: #fff; box-shadow: 0 2px 8px rgba(99, 102, 241, .35); }

/* ---------- page preview ---------- */
.page-preview { display: flex; flex-direction: column; align-items: center; gap: 9px; margin-top: 8px; }
.pp-page {
  width: 100%;
  max-width: 230px;
  aspect-ratio: var(--pp-ar, 210 / 297);
  background: #f4f6fb;
  border-radius: 4px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .45);
  position: relative;
  overflow: hidden;
}
.pp-margin { position: absolute; border: 1.5px dashed rgba(99, 102, 241, .55); border-radius: 2px; }
.pp-img { position: absolute; background: var(--grad); opacity: .85; border-radius: 1px; transition: all .2s ease; }
.pp-caption { font-size: 11.5px; color: var(--faint); text-align: center; }

/* ---------- tips / footer ---------- */
.tips { list-style: none; margin: 0; padding: 0 0 4px; }
.tips li { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; line-height: 1.5; padding-left: 18px; position: relative; }
.tips li::before { content: "✓"; position: absolute; left: 0; top: 0; color: var(--ok); font-weight: 700; }
.footer-note {
  font-size: 11px;
  color: var(--faint);
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 4px;
  line-height: 1.5;
}

/* ============================================================
   DROP ZONE
   ============================================================ */
.dropzone {
  flex: 1;
  min-height: 320px;
  border: 2px dashed rgba(148, 163, 184, .35);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: rgba(255, 255, 255, .015);
}
.dropzone:hover { border-color: rgba(34, 211, 238, .55); background: rgba(34, 211, 238, .03); }
.stage.drag-over .dropzone { border-color: var(--cyan); background: rgba(34, 211, 238, .05); }
.hero-icon { filter: drop-shadow(0 8px 22px rgba(34, 211, 238, .35)); }
.hero-title { font-size: 22px; font-weight: 800; margin: 6px 0 0; }
.hero-sub { color: var(--muted); font-size: 13.5px; max-width: 440px; line-height: 1.6; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.chip {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 4px 11px;
  border-radius: 99px;
}
.dropzone .btn { margin-top: 12px; }

.add-strip {
  flex: 0 0 auto;
  border: 2px dashed rgba(148, 163, 184, .35);
  border-radius: 14px;
  padding: 15px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 16px;
  transition: border-color .2s, background .2s, color .2s;
  color: var(--muted);
  font-size: 13.5px;
}
.add-strip:hover { border-color: rgba(34, 211, 238, .55); color: var(--text); background: rgba(34, 211, 238, .03); }
.stage.drag-over .add-strip { border-color: var(--cyan); color: var(--text); background: rgba(34, 211, 238, .05); }
.add-strip b { color: var(--cyan); }

/* ============================================================
   FILE GRID
   ============================================================ */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
  gap: 14px;
  align-content: start;
}
.file-item {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  cursor: grab;
  transition: border-color .18s, transform .18s, box-shadow .18s, opacity .18s;
  animation: itemIn .25s ease;
}
@keyframes itemIn { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
.file-item:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(0, 0, 0, .4);
}
.file-item.dragging { opacity: .35; }
.file-item.drop-target { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(34, 211, 238, .4); }
.file-item:active { cursor: grabbing; }

.thumb {
  aspect-ratio: 4 / 3;
  border-radius: 9px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
}
.thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }

.checker {
  background-color: #171c2b;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, .05) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .05) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, .05) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .05) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 9px 9px;
}

.item-name {
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-meta { font-size: 11.5px; color: var(--faint); margin-top: 2px; }

.page-badge {
  position: absolute;
  top: -8px;
  left: -8px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  background: var(--grad);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(99, 102, 241, .45);
  z-index: 2;
}
.item-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(10, 14, 26, .88);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.file-item:hover .item-remove { opacity: 1; }
.item-remove:hover { color: #fff; background: #e11d48; }

/* busy state */
.app.busy .sidebar,
.app.busy .file-grid,
.app.busy .dropzone,
.app.busy .add-strip { pointer-events: none; opacity: .55; }

/* ============================================================
   OVERLAY (progress / result)
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 8, 16, .64);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(500px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  background: #10162a;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  animation: pop .25s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grad);
  box-shadow: 0 8px 26px rgba(99, 102, 241, .45);
}
.modal-title { margin: 0; font-size: 19px; text-align: center; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pbar { height: 10px; border-radius: 6px; background: rgba(255, 255, 255, .08); overflow: hidden; margin: 20px 0 10px; }
.pbar-fill {
  height: 100%;
  width: 0%;
  background: var(--grad);
  border-radius: 6px;
  transition: width .25s ease;
  box-shadow: 0 0 14px rgba(34, 211, 238, .6);
}
.prog-meta { text-align: center; color: var(--muted); font-size: 12.5px; min-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90%; margin: 0 auto; }

.result-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 18px; }
.rm-cell { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.rm-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin-bottom: 3px; }
.rm-value { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.warn-box {
  background: rgba(248, 113, 113, .08);
  border: 1px solid rgba(248, 113, 113, .32);
  color: #fca5a5;
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 12.5px;
  margin-top: 14px;
  line-height: 1.5;
}
.warn-box ul { margin: 6px 0 0; padding-left: 18px; }

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

/* ============================================================
   LIGHTBOX
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(4, 7, 14, .84);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 30px;
  animation: fadeIn .18s ease;
}
.lb-frame {
  max-width: min(92vw, 1100px);
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
  overflow: hidden;
}
.lb-frame img { max-width: min(88vw, 1060px); max-height: 72vh; object-fit: contain; }
.lb-caption { color: var(--muted); font-size: 13px; }
.lb-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(16, 22, 42, .9);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-close:hover { background: #e11d48; color: #fff; }

/* ============================================================
   TOASTS
   ============================================================ */
.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, 92vw);
}
.toast {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #141b31;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--cyan);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .5);
  transform: translateX(120%);
  opacity: 0;
  transition: transform .3s cubic-bezier(.2, .9, .3, 1.1), opacity .3s;
}
.toast.show { transform: none; opacity: 1; }
.toast .t-ico { flex: 0 0 auto; font-size: 14px; line-height: 1.35; }
.toast.success { border-left-color: var(--ok); }
.toast.warn { border-left-color: #fbbf24; }
.toast.error { border-left-color: var(--danger); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
#sidebarToggle { display: none; }

@media (max-width: 1060px) {
  #sidebarToggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 90;
    transform: translateX(-105%);
    transition: transform .25s ease;
    background: #0d1120;
    box-shadow: 20px 0 60px rgba(0, 0, 0, .5);
    max-width: 88vw;
  }
  .sidebar.open { transform: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  .brand-sub { display: none; }
  .brand-name { font-size: 14px; }
  .stats { display: none; }
  .stage { padding: 12px; }
  .btn { padding: 8px 12px; font-size: 12.5px; }
  .btn-label { display: none; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
  .dropzone { min-height: 260px; padding: 32px 16px; }
  .hero-title { font-size: 18px; }
  .hero-sub { font-size: 12.5px; }
  .modal { padding: 22px 18px; }
}
