/* Layout: a slim tool rail on the left (a wrapping strip on phones) and one work area on the right.
   The work area uses numbered ledgers: "Sl." serials run down file lists, and each line shows the
   exact pages it takes in the result, so the order can be checked before anything is saved.
   Colour: cool blue-grey paper, ink, one blue accent. Type: Bricolage Grotesque for headings,
   IBM Plex Sans for text, IBM Plex Mono for serials, page counts and sizes. */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --ink: #13202a;
  --muted: #566775;
  --line: #d5dde3;
  --accent: #1f6bff;
  --accent-ink: #ffffff;
  --accent-soft: #e6efff;
  --danger: #b3261e;
  --danger-soft: #fbe7e5;
  --ok: #1e7a4c;
  --font-display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
  padding: 0;
  color-scheme: light;
}
html { color-scheme: light; scroll-behavior: smooth; scroll-padding-top: 76px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  max-width: 1012px;
  margin: 0 auto;
  padding: 24px 16px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}
/* Only the open tool is shown. Moving to another tool is done from the home page, so a stray click cannot lose work. */
.app .nav, .app .rail-note { display: none !important; }
.app { max-width: 1012px; }

/* Tool rail */
.rail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.brand .by {
  display: block;
  margin-top: 2px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0;
  color: var(--accent);
}
.brand small {
  display: block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav { display: flex; flex-wrap: wrap; gap: 6px; }
@media (min-width: 820px) { .nav { flex-direction: column; flex-wrap: nowrap; } }
.nav button {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 500;
  color: var(--muted);
}
.nav button:hover { background: var(--surface); color: var(--ink); }
.nav button[aria-current="page"] {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
.rail-note { font-size: 12.5px; color: var(--muted); max-width: 30ch; margin: 0; }

/* Work area */
.stage { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.stage h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(26px, 4vw, 34px);
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-wrap: balance;
}
.stage .lede { margin: 6px 0 0; color: var(--muted); max-width: 64ch; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.loading { color: var(--muted); padding: 24px 0; }

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  padding: 28px 16px;
  background: var(--surface);
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.drop:hover, .drop.is-over, .drop:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { font-weight: 600; font-size: 16px; }
.drop span { color: var(--muted); font-size: 13.5px; }
.drop input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.drop.is-busy { opacity: 0.6; pointer-events: none; }

.notices { display: flex; flex-direction: column; gap: 6px; }
.notice {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13.5px;
  overflow-wrap: anywhere;
}
.notice.info { background: var(--accent-soft); color: var(--ink); }

.ledger-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.ledger-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.ledger-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.link-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 10px;
  font-family: var(--font-body);
  font-size: 12.5px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}
.link-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.link-btn:disabled { opacity: 0.45; cursor: default; }

.ledger { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: auto 2.25rem minmax(0, 1fr) auto;
  gap: 8px 10px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.row:last-child { border-bottom: 0; }
.row.is-dragging { opacity: 0.45; }
.row.is-over { box-shadow: inset 0 2px 0 var(--accent); }
.grip { color: var(--muted); cursor: grab; display: grid; place-items: center; touch-action: none; }
.sl {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 15px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.fname { font-weight: 500; overflow-wrap: anywhere; min-width: 0; }
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.meta .out { color: var(--ok); }
.actions { display: flex; gap: 4px; }
.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
}
.icon-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.remove:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
.empty { padding: 22px 14px; color: var(--muted); font-size: 14px; }

.footbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: end;
  justify-content: space-between;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.totals { font-family: var(--font-mono); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.totals b { color: var(--ink); font-weight: 500; }
.out-name { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; min-width: 0; }
.out-name label { font-size: 12.5px; color: var(--muted); }
.out-name input {
  width: 100%;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}
.btn {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 600;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.secondary { background: transparent; color: var(--accent); }
.btn.small { padding: 6px 12px; font-size: 13.5px; }

.result {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  border: 1px solid var(--ok);
  border-radius: 10px;
  background: var(--surface);
}
.result p { margin: 0; }
.result .big { font-weight: 600; }
.result .sub { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.result .btns { display: flex; flex-wrap: wrap; gap: 8px; }
.status { font-size: 13px; color: var(--muted); min-height: 1.4em; }

/* Shared building blocks for the tools */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: -0.01em;
}
.fieldrow { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .field > .lab { font-size: 12.5px; color: var(--muted); }
.field input[type="text"], .field input[type="number"], .field select {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 0;
  width: 100%;
}
.field input[type="number"] { width: 6.5rem; font-variant-numeric: tabular-nums; }
.field input[type="color"] {
  width: 44px; height: 36px; padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.field.grow { flex: 1 1 220px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.err { margin: 0; font-size: 13px; color: var(--danger); overflow-wrap: anywhere; }
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}
.seg button {
  background: transparent;
  border: 0;
  padding: 7px 14px;
  font-weight: 500;
  color: var(--muted);
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.filecard {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.filecard .fname { font-weight: 600; }
.filecard .meta { margin-top: 2px; }
.bar {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.plist {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.plist li {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.plist li:last-child { border-bottom: 0; }
.plist .nm { overflow-wrap: anywhere; min-width: 0; }
.plist .mt { font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.plist .sl { font-size: 13px; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  position: relative;
  min-width: 0;
}
.thumb.is-click { cursor: pointer; }
.thumb.is-click:hover { border-color: var(--accent); }
.thumb.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.thumb.is-removed { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger); }
.thumb-box {
  width: 128px; height: 170px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.thumb-box canvas { max-width: 100%; max-height: 100%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.thumb-label { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.thumb-actions { display: flex; gap: 4px; }
.badge {
  position: absolute; top: 6px; left: 6px;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 99px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 12px;
  display: grid; place-items: center;
  pointer-events: none;
}
.badge.danger { background: var(--danger); color: #fff; }

/* Page editor */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 2px; }
.pager { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 13px; }
.edit-stage {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  overflow: auto;
  max-height: 80vh;
}
.page-wrap {
  position: relative;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.page-wrap canvas { display: block; }
.overlay { position: absolute; inset: 0; touch-action: none; }
.overlay.tool-text { cursor: text; }
.overlay.tool-box { cursor: crosshair; }
.ann { position: absolute; user-select: none; touch-action: none; }
.ann.is-selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.ann-text { white-space: pre; line-height: 1.2; cursor: move; min-width: 1ch; }
.ann-text[contenteditable] { cursor: text; user-select: text; outline: 2px solid var(--accent); outline-offset: 2px; }
.ann-box, .ann-img { cursor: move; }
.ann-img { display: block; }
.handle {
  position: absolute; right: -8px; bottom: -8px;
  width: 14px; height: 14px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 3px;
  cursor: nwse-resize;
}
.tip { font-size: 12.5px; color: var(--muted); margin: 0; }

/* Home screen */
.app.is-home { grid-template-columns: minmax(0, 1fr); }
.app.is-home .nav, .app.is-home .rail-note { display: none; }
.home-head h1 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(26px, 4vw, 36px); letter-spacing: -0.02em; line-height: 1.1; }
.home-head p { margin: 8px 0 0; color: var(--muted); max-width: 62ch; }
.home-group { display: flex; flex-direction: column; gap: 10px; }
.home-group h2 { margin: 8px 0 0; font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.card {
  --tint: var(--accent);
  text-align: left; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 18px 20px; color: var(--ink); cursor: pointer; min-height: 150px;
  transition: border-color .12s, transform .12s, box-shadow .12s;
}
.card:hover { border-color: var(--tint); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.card:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; }
.card .tile {
  width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center;
  color: var(--tint); background: color-mix(in srgb, var(--tint) 16%, var(--surface));
}
.card .tile svg { width: 24px; height: 24px; }
.card .ct { font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; margin-top: 4px; }
.card .cd { font-size: 13.5px; color: var(--muted); line-height: 1.4; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.toolbar .btn { padding: 7px 14px; }
.next-wrap { display: inline-flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.next-menu { display: flex; flex-wrap: wrap; gap: 6px; max-width: 420px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Home cards are real links (so each tool address can be found and opened in a new tab) */
a.card { text-decoration: none; box-sizing: border-box; }

/* Written content under the tool: what it does, how to use it, limits, questions */
.seo { max-width: 1012px; margin: 40px auto 0; padding: 28px 16px 0; color: var(--ink); }
.seo > :first-child { }
.seo:empty { display: none; }
.seo h2 { font-family: var(--font-display); font-size: 20px; letter-spacing: -0.01em; margin: 26px 0 8px; }
.seo h2:first-child { margin-top: 0; }
.seo h3 { font-size: 15.5px; font-weight: 600; margin: 16px 0 4px; }
.seo p, .seo li { color: var(--ink); max-width: 72ch; }
.seo ol, .seo ul { padding-left: 22px; margin: 8px 0; }
.seo li { margin: 4px 0; }
.seo a { color: var(--accent); }
.seo .tool-links { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 16px; }
.seo .tool-links li { margin: 0; }
.seo-note { color: var(--muted); font-size: 13.5px; }

/* ---------- Header and footer ---------- */
.site-head { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 1px 8px rgba(19,32,42,.05); }
.site-head .wrap { max-width: 1012px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px 24px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; white-space: nowrap; }
.logo i { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-style: normal; font-size: 13px; font-family: var(--font-mono); background: linear-gradient(135deg, #e4572e, #8e4fd0 55%, #2f6fe4); }
.logo small { font-family: var(--font-body); font-weight: 500; font-size: 12.5px; color: var(--accent); margin-left: 2px; }
.site-nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a { padding: 7px 12px; border-radius: 999px; text-decoration: none; color: var(--ink); font-weight: 500; font-size: 14px; white-space: nowrap; }
.site-nav a:hover { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 640px) { .logo small { display: none; } .site-head .wrap { gap: 8px; } }
.site-foot { margin-top: 48px; background: #f5f7fa; border-top: 1px solid var(--line); }
.site-foot .wrap { max-width: 1012px; margin: 0 auto; padding: 24px 16px 32px; display: flex; flex-wrap: wrap; gap: 12px 28px; justify-content: space-between; font-size: 13.5px; color: var(--muted); }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.site-foot a { color: var(--ink); text-decoration: none; font-weight: 500; }
.site-foot a:hover { color: var(--accent); text-decoration: underline; }
.site-foot p { margin: 0; max-width: 52ch; }

/* ---------- Home: bright, colourful tool boxes ---------- */
.home-head { text-align: center; padding: 18px 0 6px; }
.home-head h1 { font-size: clamp(28px, 5vw, 42px); }
.home-head p { margin-left: auto; margin-right: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.chips span { font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 999px; background: #eefaf3; color: #1e7a4c; border: 1px solid #cdeedb; }
.chips span:nth-child(2) { background: #eef3ff; color: #2f5fc4; border-color: #d3defa; }
.chips span:nth-child(3) { background: #fff3ec; color: #c2501f; border-color: #fbdcca; }
.home-group h2 { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); margin-top: 14px; }
.home-group h2::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--gc, var(--accent)); }
a.card { background: color-mix(in srgb, var(--tint) 9%, #fff); border: 1px solid color-mix(in srgb, var(--tint) 28%, #fff); border-top: 4px solid var(--tint); }
a.card:hover { background: color-mix(in srgb, var(--tint) 14%, #fff); border-color: var(--tint); }
.card .tile { background: var(--tint); color: #fff; box-shadow: 0 4px 10px color-mix(in srgb, var(--tint) 35%, transparent); }
.card .ct { color: color-mix(in srgb, var(--tint) 55%, #13202a); }

/* ---------- Info sections (About, Privacy, Terms, Contact) ---------- */
.info { margin: 28px 0 0; padding: 20px 22px; border: 1px solid var(--line); border-left: 5px solid var(--ic, var(--accent)); border-radius: 12px; background: color-mix(in srgb, var(--ic, var(--accent)) 5%, #fff); scroll-margin-top: 76px; }
.info h2 { margin-top: 0 !important; }
.info:target { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ic, var(--accent)) 30%, transparent); }

.logo img { width: 32px; height: 32px; border-radius: 8px; display: block; }
.logo b { color: var(--accent); font-weight: 700; }
.home-head { background: radial-gradient(ellipse at 50% 0, #e6f0ff 0, #fff 70%); border-radius: 20px; padding: 28px 12px 14px; }
