/* Site-wide tokens and chrome. Tool stylesheets load after this one. */
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque-latin.woff2") format("woff2");
  font-weight: 600 800; font-style: normal; font-display: swap;
}

:root {
  --bg: #fbfaf7;
  --panel: #ffffff;
  --text: #1b2230;
  --muted: #5f6878;
  --line: #e3e6ec;
  --head: #f1f2f5;
  --grp: #f5f6f9;
  --accent: #2563eb;
  --warn-bg: #fff6df;
  --warn: #8a5a00;
  --err-bg: #fdecec;
  --err: #b42323;
  --ok: #1d7a3e;
  --mark: #ffe58a;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  /* Personality: ink outlines with offset shadows in the group colour (--c), and an amber highlighter. */
  --edge: #1b2230;
  --amber: #fbbf24;
  --c: #2563eb;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --panel: #1a1e26;
    --text: #e6e9ef;
    --muted: #949cab;
    --line: #2b313c;
    --head: #232833;
    --grp: #1e232c;
    --accent: #7aa7ff;
    --warn-bg: #3a2f12;
    --warn: #f0c46a;
    --err-bg: #3d1a1a;
    --err: #ff9b9b;
    --ok: #6fd18f;
    --mark: #6b5a12;
    --edge: #525b6c;
    --amber: #d9a21b;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
/* Below the header: tool sidebar on the left, page (main + footer) on the right. */
.shell { flex: 1 0 auto; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.page { display: flex; flex-direction: column; min-width: 0; }
.page > main, .page > .layout { flex: 1 0 auto; }
a { color: var(--accent); }
.muted { color: var(--muted); }
h1, h2 { font-family: var(--display); letter-spacing: -0.02em; }

button {
  font: inherit; cursor: pointer;
  padding: 5px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--head); color: var(--text);
}

/* Header: logo and breadcrumb trail on the left, nav or tool controls on the right. */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.trail { display: flex; flex: 1 1 auto; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.trail a { color: var(--muted); text-decoration: none; }
.trail a:hover { color: var(--text); }
.trail .sep { color: var(--line); }
.trail [aria-current] { font-weight: 600; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 800 19px var(--display); letter-spacing: -0.01em; }
.trail .brand { color: var(--text); }
.brand .logo { display: block; flex: none; }
/* The tool's group in the trail, as a chip in the group's colour. */
.trail .crumb-cat {
  padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  color: color-mix(in srgb, var(--c) 80%, var(--text)); background: color-mix(in srgb, var(--c) 13%, var(--panel));
}
/* Donate: the one filled button in the header, amber with the site's ink edge and offset shadow. */
/* Flags: in the footer's "Made in" line and, on wider screens, at the top right. */
.flag { display: inline-block; vertical-align: -1px; border-radius: 2px; box-shadow: 0 0 0 1px rgb(0 0 0 / .15); }
.top-made { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; white-space: nowrap; }
@media (max-width: 520px) { .top-made { display: none; } }
.top-donate {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 999px;
  background: var(--amber); color: #1b2230; font-weight: 700; text-decoration: none; white-space: nowrap;
  border: 1.5px solid var(--edge); box-shadow: 2px 2px 0 var(--edge);
  transition: transform .12s, box-shadow .12s;
}
.top-donate:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--edge); }
.top-donate:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--edge); }
.top-donate .heart { color: #d43c5c; }

/* Donate pinned to the bottom of the sidebar: pushed down when the list is short, and stuck to
   the bottom edge while a long list scrolls behind it. */
.sidebar { display: flex; flex-direction: column; }
.side-donate {
  position: sticky; bottom: -32px; margin: auto -14px -32px; padding: 14px 18px 18px;
  background: var(--panel); border-top: 1px solid var(--line);
}
.side-donate a {
  display: flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px; border-radius: 999px;
  background: var(--amber); color: #1b2230; font-weight: 700; text-decoration: none;
  border: 1.5px solid var(--edge); box-shadow: 2px 2px 0 var(--edge);
  transition: transform .12s, box-shadow .12s;
}
.side-donate a:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--edge); }
.side-donate a:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--edge); }
.side-donate .heart { color: #d43c5c; }
.side-donate p { margin: 8px 2px 0; font-size: 12px; line-height: 1.4; color: var(--muted); text-align: center; }
.foot-site a.donate { display: inline-flex; align-items: center; gap: 5px; color: var(--text); font-weight: 600; }
.foot-site a.donate .heart { color: #d43c5c; }
.foot-site a.donate:hover { color: var(--accent); }

.narrow { width: 100%; max-width: 760px; margin: 36px auto; padding: 0 16px; }
/* Tool page headings: display face with an amber highlighter stroke underneath. */
/* `main` outranks the `.intro h1` sizes in tool stylesheets, so every tool gets the same heading. */
main .intro > h1 { font-size: 36px; line-height: 1.1; font-weight: 800; letter-spacing: -0.03em; }
@media (max-width: 600px) { main .intro > h1 { font-size: 30px; } }
.intro > h1::after {
  content: ""; display: block; width: 56px; height: 6px; margin-top: 6px; border-radius: 3px;
  background: var(--amber); transform: rotate(-1deg);
}

.note { border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.error { background: var(--err-bg); color: var(--err); }
.note.error p { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; }
.page > .note { margin: 12px 16px; }

.foot { padding: 16px 24px 28px; color: var(--muted); font-size: 12px; }
.foot-extra, .foot-site, .foot-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; }
/* Credit, "Made in" and links in one left-aligned row; on phones each gets its own line. */
.made-in { display: inline-flex; align-items: center; gap: 5px; }
.foot .flag { width: 15px; height: 9px; vertical-align: 0; }
@media (max-width: 860px) {
  .foot { padding: 16px 16px 28px; }
  .foot-links { flex-basis: 100%; column-gap: 16px; }
}
.foot-extra { margin-bottom: 8px; }
.foot-site a { color: var(--muted); }
.foot-site a:hover { color: var(--text); }

/* Cookie notice: floats at the bottom until dismissed (remembered in localStorage by layout.php). */
.cookie-bar {
  position: fixed; z-index: 50; left: 16px; right: 16px; bottom: 16px;
  max-width: 620px; margin: 0 auto; padding: 12px 14px 12px 18px;
  display: flex; align-items: center; gap: 16px;
  background: var(--panel); border: 1.5px solid var(--edge); border-radius: 14px; box-shadow: 4px 4px 0 var(--edge);
}
.cookie-bar[hidden] { display: none; }
.cookie-bar p { margin: 0; flex: 1; }
.cookie-bar button { flex: none; background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; padding: 7px 16px; }
@media (max-width: 480px) { .cookie-bar { flex-direction: column; align-items: stretch; gap: 10px; } }

/* Icon tile in a group's colour (home page rows, group headings). */
.tile {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, var(--panel));
  border: 1.5px solid color-mix(in srgb, var(--c) 32%, var(--panel));
}
.tile .icon { width: 19px; height: 19px; }

/* Left sidebar: every tool, grouped by category. --top-h is the header height, set by layout.php. */
.sidebar {
  position: sticky; top: var(--top-h, 53px); align-self: start;
  height: calc(100vh - var(--top-h, 53px)); overflow: auto;
  padding: 22px 14px 32px; border-right: 1px solid var(--line); background: var(--panel);
}
.side-cat + .side-cat { margin-top: 18px; }
.side-cat-name {
  display: flex; align-items: center; gap: 8px; padding: 0 10px 6px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); text-decoration: none;
}
.side-cat-name::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--c); }
/* Hovering a group heading turns its name and chevron the group's colour. */
.side-cat-name { transition: color .12s; }
.side-cat-name:hover { color: color-mix(in srgb, var(--c) 80%, var(--text)); }
/* Group headings toggle their group open and shut; the chevron points down when open. */
summary.side-cat-name { cursor: pointer; list-style: none; user-select: none; border-radius: 6px; }
summary.side-cat-name::-webkit-details-marker { display: none; }
summary.side-cat-name::after {
  content: ""; width: 6px; height: 6px; margin: 0 4px 3px auto;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg); transition: transform .15s;
}
details.side-cat:not([open]) > summary.side-cat-name::after { transform: rotate(-45deg); margin-bottom: 0; }
summary.side-cat-name:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
details.side-cat:not([open]) > summary.side-cat-name { padding-bottom: 0; }
.sidebar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar li a {
  display: flex; align-items: flex-start; gap: 10px; padding: 6px 10px; border-radius: 10px;
  border: 1.5px solid transparent;
  color: var(--text); text-decoration: none; font-size: 14.5px; font-weight: 500; line-height: 1.35;
  transition: background-color .12s;
}
.sidebar li a:hover { background: color-mix(in srgb, var(--c) 8%, var(--panel)); }
.sidebar .icon { flex: none; margin-top: 1px; color: var(--c); }
.sidebar li a[aria-current] {
  background: color-mix(in srgb, var(--c) 10%, var(--panel)); border-color: var(--edge);
  box-shadow: 3px 3px 0 var(--c); font-weight: 600;
}
.side-open, .side-scrim { display: none; }
/* Sidebar tooltip (sidebar_tip_script in layout.php): the tool's summary beside its link, with an
   arrow pointing at it, or under it when there's no room on the right. --c is the link's group colour. */
.side-tip {
  position: fixed; z-index: 40; max-width: 260px; padding: 8px 12px; border-radius: 10px;
  background: var(--panel); color: var(--text); font-size: 13px; line-height: 1.45;
  border: 1.5px solid var(--edge); box-shadow: 3px 3px 0 var(--c);
  pointer-events: none; opacity: 0; visibility: hidden; transform: translateX(-4px);
  transition: opacity .12s, transform .12s, visibility 0s .12s;
}
.side-tip.on { opacity: 1; visibility: visible; transform: none; transition: opacity .12s, transform .12s; }
.side-tip::before {
  content: ""; position: absolute; left: -6px; top: var(--ay, 50%); width: 9px; height: 9px; margin-top: -5px;
  background: var(--panel); border: solid var(--edge); border-width: 0 0 1.5px 1.5px; transform: rotate(45deg);
}
.side-tip.below { transform: translateY(-4px); }
.side-tip.below.on { transform: none; }
.side-tip.below::before { display: none; }

/* Narrow screens: the sidebar becomes a drawer opened from the header's menu button. */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .top { gap: 10px 12px; padding: 10px 16px; }
  .trail { flex: 1 1 150px; }
  .side-open { display: inline-flex; align-self: center; cursor: pointer; color: var(--text); padding: 2px; margin: -2px 0; }
  .sidebar {
    position: fixed; z-index: 30; top: 0; left: 0; bottom: 0; width: min(300px, 85vw);
    height: auto; align-self: stretch; transform: translateX(-100%); transition: transform .2s;
  }
  .side-toggle:checked ~ .shell .sidebar { transform: none; box-shadow: 0 0 24px rgb(0 0 0 / .25); }
  .side-toggle:checked ~ .shell .side-scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgb(0 0 0 / .35); }
}

/* Home page. */
.home { width: 100%; max-width: 1080px; margin: 0 auto; padding: 44px 24px 56px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px 32px; flex-wrap: wrap; margin-bottom: 36px; }
.hero h1 { font-size: 56px; line-height: 1.02; font-weight: 800; letter-spacing: -0.035em; margin: 0 0 14px; }
.hero p { margin: 0; color: var(--muted); font-size: 17px; max-width: 30em; }
/* Amber highlighter stroke behind a word. */
.hl { position: relative; z-index: 0; white-space: nowrap; }
.hl::after {
  content: ""; position: absolute; z-index: -1; left: -4px; right: -4px; bottom: .08em; height: .32em;
  background: var(--amber); border-radius: 4px; transform: rotate(-1deg);
}
.stats { display: flex; gap: 10px; }
.stats > div {
  min-width: 76px; padding: 10px 14px; text-align: center;
  background: var(--panel); border: 1.5px solid var(--edge); border-radius: 14px; box-shadow: 3px 3px 0 var(--edge);
}
.stats b { display: block; font: 800 26px/1 var(--display); }
.stats span { font-size: 12px; font-weight: 500; color: var(--muted); }

/* Groups flow down two columns, each a card with an offset shadow in its colour. */
.groups { columns: 2 380px; column-gap: 26px; }
.group {
  break-inside: avoid; margin-bottom: 26px; overflow: hidden;
  background: var(--panel); border: 1.5px solid var(--edge); border-radius: 18px; box-shadow: 5px 5px 0 var(--c);
  scroll-margin-top: calc(var(--top-h, 53px) + 16px);
}
.group-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 10%, var(--panel)), var(--panel) 70%);
}
.group-head .tile { width: 38px; height: 38px; }
.group-head h2 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -0.015em; }
.group-head p { margin: 0; color: var(--muted); font-size: 13px; }
.count {
  margin-left: auto; align-self: flex-start; white-space: nowrap; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  color: color-mix(in srgb, var(--c) 85%, var(--text)); background: color-mix(in srgb, var(--c) 12%, var(--panel));
}
.tool-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; color: var(--text); text-decoration: none; transition: background-color .12s; }
.tool-row + .tool-row { border-top: 1px solid var(--line); }
.tool-row .tile { width: 32px; height: 32px; border-radius: 9px; }
.tool-row:hover { background: color-mix(in srgb, var(--c) 6%, var(--panel)); }
.tool-text { min-width: 0; }
.tool-text b { display: block; font-weight: 600; font-size: 15px; }
.tool-text span { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; }
.go { margin-left: auto; padding-left: 8px; color: var(--c); font-weight: 600; transition: transform .12s; }
.tool-row:hover .go { transform: translateX(3px); }
.tool-row:focus-visible { outline: 2px solid var(--c); outline-offset: -2px; }

@media (max-width: 600px) {
  .home { padding-top: 28px; }
  .hero h1 { font-size: 40px; }
  .stats { width: 100%; }
  .stats > div { min-width: 0; flex: 1; }
}

/* File drop zone used by upload tools: the whole box is the file input. */
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin: 20px 0; padding: 40px 20px; text-align: center;
  background: var(--panel); border: 2px dashed color-mix(in srgb, var(--c) 40%, var(--line)); border-radius: 16px;
  transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--c); background: color-mix(in srgb, var(--c) 6%, var(--panel)); }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dz-icon { width: 44px; height: 44px; color: var(--c); }
.dz-btn {
  background: var(--accent); color: #fff; padding: 10px 24px; border-radius: 12px; font-size: 16px; font-weight: 600;
  border: 1.5px solid var(--edge); box-shadow: 3px 3px 0 var(--edge);
}
.dz-hint { color: var(--muted); font-size: 13px; }
.dropzone noscript button { position: relative; z-index: 1; }
.busy { opacity: .6; pointer-events: none; }

/* Long-form text (privacy policy). */
.prose { font-size: 15px; line-height: 1.6; }
.prose h1 { font-size: 30px; margin: 0 0 4px; }
.prose h2 { font-size: 19px; margin: 28px 0 6px; }
.prose ul { padding-left: 20px; }
.prose li + li { margin-top: 4px; }
.prose code { font-family: var(--mono); font-size: .9em; background: var(--head); padding: 0 4px; border-radius: 3px; }

@media print {
  .top, .foot, .sidebar, .side-scrim, .side-tip { display: none !important; }
  body, .shell, .page { display: block; min-height: 0; }
}
