/* ============================================================
   PDF PRESS — browser PDF toolkit
   Style: Micro-interactions / minimal utility. Teal primary,
   orange accent. Light + dark. Plus Jakarta Sans.
   ============================================================ */

:root {
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* light theme (default) */
  --bg:        #eefdf9;
  --bg-tint:   radial-gradient(1100px 520px at 78% -8%, #d6f7ef 0%, transparent 60%),
               radial-gradient(900px 480px at 8% 4%, #e6f0f4 0%, transparent 55%);
  --surface:   #ffffff;
  --surface-2: #f4fbf9;
  --fg:        #103a36;
  --fg-2:      #4f726c;
  --fg-3:      #7d9893;
  --primary:   #0d9488;
  --primary-d: #0b7d73;
  --primary-soft: #d5f3ef;
  --on-primary:#ffffff;
  --accent:    #ea580c;
  --accent-d:  #c2440a;
  --accent-soft:#fde6d8;
  --border:    #d3ede8;
  --border-2:  #bfe4dd;
  --ring:      #0d9488;
  --good:      #0f9d58;
  --bad:       #dc2626;
  --shadow-sm: 0 1px 2px rgba(16,58,54,.06), 0 1px 1px rgba(16,58,54,.04);
  --shadow-md: 0 6px 18px -6px rgba(16,58,54,.18), 0 2px 6px -2px rgba(16,58,54,.10);
  --shadow-lg: 0 18px 40px -12px rgba(16,58,54,.26);
  --radius:    16px;
  --radius-sm: 11px;
  --maxw:      980px;
}

[data-theme="dark"] {
  --bg:        #042b28;
  --bg-tint:   radial-gradient(1100px 540px at 80% -10%, #0a423c 0%, transparent 60%),
               radial-gradient(820px 460px at 6% 2%, #073531 0%, transparent 55%);
  --surface:   #073d39;
  --surface-2: #0a443f;
  --fg:        #dff6f1;
  --fg-2:      #9cc4bd;
  --fg-3:      #6f9a93;
  --primary:   #2dd4bf;
  --primary-d: #14b8a6;
  --primary-soft: #0f4d47;
  --on-primary:#04302b;
  --accent:    #fb7c3c;
  --accent-d:  #f9692a;
  --accent-soft:#3a2417;
  --border:    #115049;
  --border-2:  #176057;
  --ring:      #2dd4bf;
  --good:      #34d399;
  --bad:       #f87171;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.30);
  --shadow-md: 0 8px 22px -8px rgba(0,0,0,.55);
  --shadow-lg: 0 22px 46px -14px rgba(0,0,0,.65);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body { background-image: var(--bg-tint); background-attachment: fixed; }
::selection { background: var(--primary); color: var(--on-primary); }

a { color: var(--primary-d); }
[data-theme="dark"] a { color: var(--primary); }

.hidden { display: none !important; }

.app {
  position: relative;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 24px 40px;
  display: flex; flex-direction: column; gap: 26px;
}

/* ---- topbar ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  background: none; border: none; cursor: pointer; padding: 6px 4px;
  font-family: var(--font); color: var(--fg);
}
.brand-glyph {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 11px; color: var(--on-primary);
  background: linear-gradient(140deg, var(--primary), var(--primary-d));
  box-shadow: var(--shadow-sm);
}
.brand-word { font-weight: 800; font-size: 19px; letter-spacing: -0.02em; }
.brand:hover .brand-glyph { transform: translateY(-1px) rotate(-3deg); }
.brand-glyph { transition: transform .18s ease-out; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.seg {
  min-height: 40px; min-width: 44px; padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border); border-radius: 999px;
  font-family: var(--font); font-weight: 700; font-size: 13px; letter-spacing: .04em;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .15s ease-out, border-color .15s, background .15s, color .15s;
}
.seg:hover { transform: translateY(-1px); border-color: var(--primary); color: var(--primary-d); }
.seg:active { transform: translateY(0) scale(.97); }
.icon-btn { padding: 0; width: 40px; }
.seg:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

/* ---- hero ---- */
.hero { padding: 8px 2px 0; }
.hero h1 {
  margin: 0; font-weight: 800; letter-spacing: -0.035em;
  font-size: clamp(34px, 6vw, 60px); line-height: 1.02;
  background: linear-gradient(135deg, var(--fg) 30%, var(--primary-d));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  max-width: 16ch;
}
.sub { margin: 18px 0 0; max-width: 62ch; color: var(--fg-2); font-size: 16.5px; }

/* ---- breadcrumb ---- */
.crumb { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crumb-link {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); color: var(--fg-2);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px; font-family: var(--font); font-weight: 600; font-size: 14px;
  cursor: pointer; min-height: 40px; box-shadow: var(--shadow-sm);
  transition: transform .15s ease-out, color .15s, border-color .15s;
}
.crumb-link svg { display: block; }
.crumb-link:hover { transform: translateX(-2px); color: var(--primary-d); border-color: var(--primary); }
.crumb-cur { font-weight: 700; color: var(--fg); }

/* ============================================================
   TOOL GRID
   ============================================================ */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(214px, 1fr)); gap: 14px; }
.card {
  position: relative; isolation: isolate;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 156px;
  display: flex; flex-direction: column; gap: 4px;
  text-align: left; cursor: pointer;
  font-family: var(--font); color: var(--fg);
  box-shadow: var(--shadow-sm);
  transition: transform .18s cubic-bezier(.22,1,.36,1), box-shadow .18s, border-color .18s;
  animation: cardIn .5s cubic-bezier(.22,1,.36,1) both;
  animation-delay: calc(var(--i, 0) * 34ms);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card-ico-wrap {
  display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 12px;
  border-radius: 12px; color: var(--primary-d);
  background: var(--primary-soft);
  transition: background .18s, color .18s, transform .18s;
}
.card-ico { display: block; }
.card-title { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.card-desc { font-size: 13.5px; color: var(--fg-2); line-height: 1.45; }
.card-go {
  position: absolute; right: 16px; bottom: 16px; color: var(--accent);
  opacity: 0; transform: translateX(-6px);
  transition: opacity .18s, transform .18s;
}
.card:hover {
  transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--border-2);
}
.card:hover .card-ico-wrap { background: var(--primary); color: var(--on-primary); transform: scale(1.05) rotate(-3deg); }
.card:hover .card-go { opacity: 1; transform: translateX(0); }
.card:active { transform: translateY(-1px) scale(.99); }
.card:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

/* ============================================================
   PANEL (mounted tool)
   ============================================================ */
.panel, .tool-body { display: flex; flex-direction: column; gap: 18px; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-md);
  animation: panelIn .28s cubic-bezier(.22,1,.36,1) both;
}
@keyframes panelIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- dropzone ---- */
.dz {
  border: 1.5px dashed var(--border-2); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 44px 24px; text-align: center;
  color: var(--fg-2); cursor: pointer;
  transition: background .15s, border-color .15s, transform .12s;
}
.dz:hover, .dz:focus-visible { background: var(--primary-soft); border-color: var(--primary); color: var(--fg); outline: none; }
.dz.drag { background: var(--primary-soft); border-color: var(--primary); border-style: solid; transform: scale(1.006); }
.dz-ico { color: var(--primary-d); }
.dz-title { margin: 12px 0 4px; font-weight: 700; font-size: 18px; color: var(--fg); }
.dz-hint { margin: 0; font-size: 13.5px; color: var(--fg-2); }

/* ---- fields ---- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-weight: 700; font-size: 14px; }
.field-label output { color: var(--accent-d); font-variant-numeric: tabular-nums; }
[data-theme="dark"] .field-label output { color: var(--accent); }
.field-hint { font-size: 12.5px; color: var(--fg-3); line-height: 1.45; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
label.inline { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 32px; }

input[type="text"], input[type="number"], select, textarea {
  font-family: var(--font); font-size: 15px; color: var(--fg);
  background: var(--surface); border: 1.5px solid var(--border-2);
  border-radius: 10px; padding: 11px 13px; min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; min-height: 84px; width: 100%; line-height: 1.5; }
input[type="color"] { width: 48px; height: 44px; padding: 3px; border: 1.5px solid var(--border-2); border-radius: 10px; background: var(--surface); cursor: pointer; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%;
  height: 6px; border-radius: 999px; background: var(--border-2); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); cursor: pointer; border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm); transition: transform .12s;
}
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); cursor: pointer; border: 3px solid var(--surface);
}

/* ---- buttons ---- */
button, .primary {
  font-family: var(--font); font-weight: 700; font-size: 15px;
  border-radius: 12px; cursor: pointer; border: 1px solid transparent;
  padding: 13px 20px; min-height: 46px;
  transition: transform .15s ease-out, box-shadow .15s, background .15s, color .15s, border-color .15s;
}
.primary {
  background: linear-gradient(140deg, var(--primary), var(--primary-d));
  color: var(--on-primary); text-align: center; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: var(--shadow-sm); border: none;
}
.primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.primary:active { transform: translateY(0) scale(.98); }
.primary:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; filter: grayscale(.3); }
.ghost {
  background: var(--surface); color: var(--fg);
  border: 1.5px solid var(--border-2); padding: 11px 16px; min-height: 44px;
}
.ghost:hover { border-color: var(--primary); color: var(--primary-d); transform: translateY(-1px); }
.ghost:active { transform: scale(.98); }
button:focus-visible, .primary:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

/* ---- progress ---- */
.bar { height: 10px; background: var(--border-2); border-radius: 999px; overflow: hidden; }
.barfill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .25s ease-out;
}
.status { margin: 0; font-size: 13.5px; color: var(--fg-2); text-align: center; }
.status.bad { color: var(--bad); }
.status.good { color: var(--good); }

/* ---- stats ---- */
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 110px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; text-align: center; display: flex; flex-direction: column; gap: 5px;
}
.stat-label { font-size: 11px; color: var(--fg-3); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.stat-val { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat.saved { background: var(--accent-soft); border-color: transparent; }
.stat.saved .stat-val { color: var(--accent-d); }
[data-theme="dark"] .stat.saved .stat-val { color: var(--accent); }

/* ---- thumbnails ---- */
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; }
.thumb {
  position: relative; background: var(--surface-2);
  border: 1.5px solid var(--border); border-radius: 12px; padding: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: grab; user-select: none;
  transition: transform .15s ease-out, box-shadow .15s, border-color .15s;
}
.thumb:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.thumb.sel { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.thumb.removed { opacity: .5; border-color: var(--bad); border-style: dashed; }
.thumb.removed::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; font-weight: 800; color: var(--bad); }
.thumb.dragging { opacity: .5; }
.thumb canvas, .thumb img { max-width: 100%; height: auto; border-radius: 6px; background: #fff; box-shadow: var(--shadow-sm); }
.thumb-label { font-size: 11.5px; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.thumb-btn {
  position: absolute; top: 5px; right: 5px;
  background: var(--surface); border: 1px solid var(--border); color: var(--bad);
  width: 26px; height: 26px; border-radius: 8px; padding: 0; font-size: 14px; line-height: 1;
  display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow-sm);
}
.thumb-btn:hover { background: var(--bad); color: #fff; border-color: var(--bad); }

/* ---- chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--primary-soft); color: var(--fg);
  border: 1px solid var(--border-2); border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 500;
}
.chip button { background: none; border: none; color: var(--fg-2); padding: 0; min-height: 0; cursor: pointer; font-size: 16px; line-height: 1; }
.chip button:hover { color: var(--bad); transform: none; }

/* ---- file list ---- */
.flist { display: flex; flex-direction: column; gap: 8px; }
.fitem {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; cursor: grab; user-select: none;
  transition: box-shadow .15s, transform .12s;
}
.fitem:hover { box-shadow: var(--shadow-sm); }
.fitem.dragging { opacity: .5; }
.fitem .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.fitem .fmeta { font-size: 12px; color: var(--fg-3); font-variant-numeric: tabular-nums; }

/* ---- text output ---- */
pre.out {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; max-height: 360px; overflow: auto; white-space: pre-wrap;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; line-height: 1.6; margin: 0; color: var(--fg);
}

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(18px);
  background: var(--fg); color: var(--bg);
  padding: 13px 20px; border-radius: 12px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
  max-width: 90vw; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.good { background: var(--good); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }

/* ---- footer ---- */
footer {
  display: flex; justify-content: center; gap: 8px 22px; flex-wrap: wrap;
  padding-top: 6px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--fg-3);
}
footer span { display: inline-flex; align-items: center; gap: 7px; }
footer span::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); opacity: .65; }

@media (max-width: 540px) {
  .app { padding: 18px 16px 32px; gap: 20px; }
  .hero h1 { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0ms !important; transition-duration: .001ms !important; }
}
