/* Georges Raad tools: shared design system. Plain CSS, no build step. */

@import url("tokens.css");

/* ---------- base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-size: var(--text-sm);
  line-height: 1.5;
  background: var(--color-bg);
  color: var(--color-text);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  color: var(--color-ink);
  font-weight: var(--weight-bold);
  line-height: 1.25;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

img {
  display: block;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ---------- utilities ---------- */

.muted {
  color: var(--color-muted);
}
.text-sm {
  font-size: var(--text-sm);
}
.text-xs {
  font-size: var(--text-xs);
}
.text-destructive {
  color: var(--color-danger);
}
.text-success {
  color: var(--color-success);
}
.row {
  display: flex;
  align-items: center;
}
.gap-2 {
  gap: var(--space-2);
}
.gap-3 {
  gap: var(--space-3);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- icons ---------- */

.icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-lg {
  width: 1.5rem;
  height: 1.5rem;
}
.icon-xl {
  width: 2rem;
  height: 2rem;
}
.spin {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* The theme toggle shows the mode you will switch to */
.i-sun {
  display: none;
}
:root[data-theme="dark"] .i-sun {
  display: block;
}
:root[data-theme="dark"] .i-moon {
  display: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun {
    display: block;
  }
  :root:not([data-theme="light"]) .i-moon {
    display: none;
  }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  font-weight: var(--weight-regular);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  transition:
    background-color var(--duration),
    border-color var(--duration),
    color var(--duration),
    opacity var(--duration),
    transform var(--duration) ease-out;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-lg {
  border-radius: var(--radius-lg);
  height: 3rem;
  padding: var(--space-2) var(--space-6);
  font-size: var(--text-md);
}
.btn-md {
  height: 2.5rem;
  padding: 0 var(--space-4);
  font-size: var(--text-md);
}
.btn-sm {
  height: 2rem;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}
.btn-icon {
  width: 2rem;
  height: 2rem;
  padding: 0;
}
.btn-primary {
  background: var(--color-ink);
  color: var(--color-on-ink);
}
.btn-primary:not(:disabled):hover {
  background: var(--color-ink-hover);
}
.btn-secondary {
  background: var(--color-field);
  color: var(--color-ink);
}
.btn-secondary:not(:disabled):hover {
  background: var(--color-field-hover);
}
.btn-outline {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-ink);
}
.btn-outline:not(:disabled):hover {
  background: var(--color-field);
}
.btn-ghost {
  background: transparent;
  color: var(--color-ink);
}
.btn-ghost:not(:disabled):hover {
  background: var(--color-field);
}
.btn-danger {
  background: transparent;
  border-color: var(--color-danger);
  color: var(--color-danger);
}
.btn-danger:not(:disabled):hover {
  background: var(--color-field);
}
.btn-block {
  width: 100%;
}

/* Press feedback: controls dip slightly while held down */
.btn:not(:disabled):active,
.option:active,
.dropdown-btn:active {
  transform: scale(0.97);
}
.btn-icon:not(:disabled):active {
  transform: scale(0.92);
}
@media (prefers-reduced-motion: reduce) {
  .btn,
  .option,
  .dropdown-btn {
    transition-property: background-color, border-color, color, opacity;
  }
  .btn:not(:disabled):active,
  .option:active,
  .dropdown-btn:active {
    transform: none;
  }
}


/* ---------- site chrome ---------- */

.topbar {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  flex-shrink: 0;
  /* Same padding as the portfolio's main page, no background or border */
  padding: 32px;
  font-size: 13px;
  line-height: 1.2;
}

/* "Georges Raad / Tools / Page": same type and colours as the main page */
.crumbs {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.crumbs ol {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  white-space: nowrap;
  color: var(--color-muted);
}
.crumbs li {
  display: flex;
  align-items: center;
}
/* Chevron separator */
.crumbs li + li::before,
.page-crumbs .sep {
  content: "";
  display: block;
  width: 11px;
  height: 11px;
  background: rgba(128, 128, 128, 0.7); /* mid grey that works in light and dark */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.crumbs li + li::before {
  margin-right: 8px;
}
.crumbs a {
  color: var(--color-text);
  text-decoration: none;
  transition: color var(--duration);
}
.crumbs a:hover {
  color: var(--color-accent);
}
.crumbs [aria-current] {
  color: var(--color-muted);
}

.topbar-sep {
  width: 1px;
  height: 12px;
  align-self: flex-start;
  background: rgba(128, 128, 128, 0.5);
  margin: 2px var(--space-4) 0; /* 2px keeps the line centred on the 15px text line; 8px gap + 16px = 24px each side */
}

.topbar-actions {
  display: flex;
  align-items: flex-start;
  flex-shrink: 0;
  margin-left: auto;
}
/* Pull the theme menu up so the breadcrumb text keeps its exact position */
.topbar-actions {
  gap: 6px;
}
.topbar .theme-switch,
.topbar .bookmark {
  margin-top: -6px;
}

.tool-tabs {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  min-width: 0;
  flex: 1;
}
/* Tabs that don't fit are moved into the "More" menu (tabs-overflow.js) */
.tool-tabs a[hidden] {
  display: none;
}
.tabs-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 var(--space-2);
  border: 0;
  background: transparent;
  color: var(--color-muted);
  font: inherit;
  cursor: pointer;
  transition: color var(--duration);
}
.tabs-more-btn:hover,
.tabs-more-btn[aria-expanded="true"],
.tabs-more-btn.has-active {
  color: var(--color-accent);
}
.tabs-more-btn svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 150ms;
}
.tabs-more-btn[aria-expanded="true"] svg {
  transform: rotate(180deg);
}
.tabs-more-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
  border-radius: 4px;
}
.tool-tabs a {
  display: block;
  padding: 0 var(--space-2);
  text-decoration: none;
  white-space: nowrap;
  color: var(--color-muted);
  transition: color var(--duration);
}
/* So the space after the | matches the space before it */
.tool-tabs > a:first-child {
  padding-left: 0;
}
.tool-tabs a:hover {
  color: var(--color-accent);
}
.tool-tabs a.active {
  color: var(--color-accent);
}

/* ---------- form controls ---------- */

.field-label {
  display: block; /* a label is inline by default, which made the gap to its input depend on the line box */
  font-size: var(--text-sm);
  color: var(--color-muted);
  padding: var(--space-2) var(--space-1) var(--space-3);
}

.field {
  display: flex;
  align-items: center;
  height: 2.5rem;
  padding: 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--color-field);
  cursor: text;
}
.field:hover {
  background: var(--color-field-hover);
}
.field:focus-within {
  border-color: var(--color-accent);
}
.field input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--color-ink);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.field input::placeholder {
  color: var(--color-muted);
  opacity: 0.55; /* lighter than the entered text */
}
.field input:disabled {
  cursor: not-allowed;
}
.field:has(input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}
.field:has(input:disabled):hover {
  background: var(--color-field);
}
/* Surface variant: white (dark grey in dark mode) with no border, for use on the page background */
.field-surface {
  background: var(--color-surface);
}
.field-surface:hover {
  background: color-mix(in srgb, var(--color-ink) 3%, var(--color-surface));
}
.field-surface:has(input:disabled):hover {
  background: var(--color-surface);
}
/* Text area (.textarea): the multi-line twin of .field, for pasted or generated code. Add .textarea-code for monospace. */
.textarea {
  display: block;
  width: 100%;
  min-height: 8rem;
  padding: var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--color-field);
  color: var(--color-ink);
  font: inherit;
  font-size: var(--text-sm);
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: background-color var(--duration), border-color var(--duration);
}
.textarea-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--text-xs);
  tab-size: 2;
  overflow-wrap: anywhere;
}
.textarea:hover {
  background: var(--color-field-hover);
}
.textarea:focus-visible {
  border-color: var(--color-accent);
}
.textarea::placeholder {
  color: var(--color-muted);
  opacity: 0.55;
}
.textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.textarea:disabled:hover {
  background: var(--color-field);
}
/* Color field (.color-field): a swatch that opens the color picker, then the hex value. Add .invalid for an error state.
     <div class="color-field"><input type="color" aria-label="Pick a color"><span class="color-field-hash" aria-hidden="true">#</span><input type="text" aria-label="Hex color"></div> */
.color-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  height: 2.5rem;
  padding: 0 var(--space-3) 0 5px; /* with the 1px border, the swatch sits 6px from the left, the same as from the top and bottom */
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--color-field);
}
.color-field:hover {
  background: var(--color-field-hover);
}
.color-field:focus-within {
  border-color: var(--color-accent);
}
.color-field.invalid {
  border-color: var(--color-danger);
}
.color-field input[type="color"] {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: none;
  cursor: pointer;
  overflow: hidden;
}
.color-field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
.color-field input[type="color"]::-webkit-color-swatch {
  border: 0;
}
.color-field input[type="color"]::-moz-color-swatch {
  border: 0;
}
.color-field .color-field-hash {
  margin-right: -0.5rem; /* cancels the 8px flex gap, so the # sits right against the value */
  font-family: var(--font-mono);
  font-size: var(--text-md);
  color: var(--color-muted);
  user-select: none;
}
.color-field input[type="text"] {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: none;
  font-family: var(--font-mono);
  font-size: var(--text-md);
  text-transform: uppercase;
}
.color-field:has(input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}
.color-field:has(input:disabled):hover {
  background: var(--color-field);
}
.color-field input:disabled {
  cursor: not-allowed;
}
/* Color picker (.cp): the popover that opens from every <input type="color">, built by color-picker.js, so it looks and works the same in
   every browser. The square sets saturation and brightness, then hue, optional opacity, and the value in Hex, RGB, HSL or HSB.
   An input with a data-alpha attribute shows its swatch over a checkerboard, so transparency is visible. */
.color-field input[type="color"][data-alpha],
input[type="color"][data-alpha] {
  -webkit-appearance: none;
  appearance: none;
  background:
    linear-gradient(var(--cp-swatch, transparent), var(--cp-swatch, transparent)),
    conic-gradient(#d4d4d4 25%, #ffffff 0 50%, #d4d4d4 0 75%, #ffffff 0) 0 0 / 10px 10px;
}
input[type="color"][data-alpha]::-webkit-color-swatch-wrapper,
input[type="color"][data-alpha]::-webkit-color-swatch {
  opacity: 0;
}
input[type="color"][data-alpha]::-moz-color-swatch {
  opacity: 0;
}
input[type="color"]:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
input[type="color"]:not(:disabled):active {
  transform: scale(0.94);
}
.cp {
  position: fixed;
  z-index: 200;
  width: 16.5rem;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  box-shadow: var(--shadow-float);
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top left;
  transition: opacity var(--duration) ease-out, transform var(--duration) ease-out;
}
.cp[hidden] {
  display: none;
}
.cp[data-side="top"] {
  transform-origin: bottom left;
  transform: translateY(4px) scale(0.98);
}
.cp.is-open {
  opacity: 1;
  transform: none;
}
.cp-area {
  position: relative;
  height: 11rem;
  border-radius: var(--radius-md);
  background:
    linear-gradient(to top, #000, transparent),
    linear-gradient(to right, #fff, var(--cp-hue, red));
  cursor: crosshair;
  touch-action: none;
  outline: none;
}
.cp-area-thumb,
.cp-range::-webkit-slider-thumb {
  box-sizing: border-box;
  border: 2px solid #ffffff;
  border-radius: var(--radius-full);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 1px 4px rgba(0, 0, 0, 0.3);
}
.cp-area-thumb {
  position: absolute;
  width: 1.125rem;
  height: 1.125rem;
  background: var(--cp-color);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: transform var(--duration) ease-out;
}
.cp-area:hover .cp-area-thumb {
  transform: translate(-50%, -50%) scale(1.1);
}
.cp-area.is-dragging .cp-area-thumb {
  transform: translate(-50%, -50%) scale(0.9);
}
.cp-area:focus-visible {
  box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-accent);
}
.cp-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.cp-eye {
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: var(--color-ink);
  cursor: pointer;
  transition: background var(--duration), transform var(--duration) ease-out;
  -webkit-tap-highlight-color: transparent;
}
.cp-eye[hidden] {
  display: none;
}
.cp-eye:hover {
  background: var(--color-field);
}
.cp-eye:active {
  transform: scale(0.92);
}
.cp-eye:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}
.cp-eye .icon {
  width: 1.125rem;
  height: 1.125rem;
}
.cp-sliders {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.cp-range {
  display: block;
  width: 100%;
  height: 0.875rem;
  margin: 0;
  border-radius: var(--radius-full);
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}
.cp-hue {
  background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.cp-alpha-track {
  border-radius: var(--radius-full);
  background: conic-gradient(#d4d4d4 25%, #ffffff 0 50%, #d4d4d4 0 75%, #ffffff 0) 0 0 / 10px 10px;
}
.cp-alpha {
  background: linear-gradient(to right, transparent, var(--cp-color, #000));
}
.cp.no-alpha .cp-alpha-track {
  display: none;
}
.cp-range::-webkit-slider-track {
  height: 0.875rem;
  background: transparent;
  border-radius: var(--radius-full);
}
.cp-range::-moz-range-track {
  height: 0.875rem;
  background: transparent;
  border-radius: var(--radius-full);
}
.cp-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1.125rem;
  height: 1.125rem;
  margin-top: -0.125rem;
  background: var(--cp-color);
  transition: transform var(--duration) ease-out;
}
.cp-hue::-webkit-slider-thumb {
  background: var(--cp-hue);
}
.cp-range::-moz-range-thumb {
  box-sizing: border-box;
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid #ffffff;
  border-radius: var(--radius-full);
  background: var(--cp-color);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 1px 4px rgba(0, 0, 0, 0.3);
  transition: transform var(--duration) ease-out;
}
.cp-hue::-moz-range-thumb {
  background: var(--cp-hue);
}
.cp-range:hover::-webkit-slider-thumb {
  transform: scale(1.1);
}
.cp-range:active::-webkit-slider-thumb {
  transform: scale(0.9);
}
.cp-range:hover::-moz-range-thumb {
  transform: scale(1.1);
}
.cp-range:active::-moz-range-thumb {
  transform: scale(0.9);
}
.cp-range:focus-visible {
  box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-accent);
}
.cp-values {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.cp-mode-wrap {
  position: relative;
  flex: none;
}
.cp-mode {
  width: 4.25rem;
  height: 2.25rem;
  padding: 0 1.5rem 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--color-field);
  color: var(--color-ink);
  font-size: var(--text-sm);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background var(--duration);
}
.cp-mode:hover {
  background: var(--color-field-hover);
}
.cp-mode:focus-visible {
  outline: none;
  border-color: var(--color-accent);
}
.cp-mode-wrap .icon {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  width: 0.875rem;
  height: 0.875rem;
  margin-top: -0.4375rem;
  color: var(--color-muted);
  pointer-events: none;
}
.cp-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  height: 2.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--color-field);
  overflow: hidden;
  transition: background var(--duration);
}
.cp-field:hover {
  background: var(--color-field-hover);
}
.cp-field:focus-within {
  border-color: var(--color-accent);
}
.cp-field input {
  min-width: 0;
  height: 100%;
  padding: 0 var(--space-2);
  border: 0;
  outline: 0;
  background: none;
  color: var(--color-ink);
  font-family: inherit;
  font-size: var(--text-sm);
}
.cp-field input[hidden] {
  display: none;
}
.cp-field input[aria-invalid="true"] {
  color: var(--color-danger);
}
.cp-hex {
  flex: 1;
  text-transform: uppercase;
  padding-left: var(--space-3);
}
.cp-num {
  flex: 1;
  width: 0;
  text-align: center;
}
.cp-opacity-box {
  flex: none;
  display: flex;
  align-items: center;
  width: 3.5rem;
  border-left: 1px solid var(--color-surface);
  cursor: text;
}
.cp.no-alpha .cp-opacity-box {
  display: none;
}
.cp-opacity {
  flex: 1;
  width: 0;
  padding-right: 0 !important;
  text-align: right;
}
.cp-pct {
  padding: 0 var(--space-2) 0 2px;
  font-size: var(--text-sm);
  color: var(--color-muted);
}
@media (prefers-reduced-motion: reduce) {
  .cp,
  .cp-area-thumb,
  .cp-range::-webkit-slider-thumb,
  .cp-eye {
    transition: none;
  }
}
.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field span {
  margin-left: var(--space-1);
  font-size: var(--text-sm);
  color: var(--color-muted);
}

select.select {
  width: 100%;
  height: 2.5rem;
  padding: 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--color-field);
  color: var(--color-ink);
  font-size: var(--text-md);
}

.dropdown {
  position: relative;
  min-width: 0;
}
.dropdown-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  height: 2.5rem;
  padding: 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--color-field);
  color: var(--color-ink);
  font-size: var(--text-md);
  text-align: left;
  transition: transform var(--duration) ease-out;
  -webkit-tap-highlight-color: transparent;
}
.dropdown-btn:hover {
  background: var(--color-field-hover);
}
.dropdown-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--color-field);
}
.dropdown-btn:focus-visible,
.dropdown-btn[aria-expanded="true"] {
  outline: none;
  border-color: var(--color-accent);
}
.dropdown-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dropdown-meta {
  margin-left: auto;
  font-size: var(--text-sm);
  color: var(--color-muted);
  white-space: nowrap;
}
.dropdown-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: var(--space-2);
  border-radius: 50%;
  vertical-align: middle;
}
.dropdown-btn .icon {
  margin-left: var(--space-1);
  color: var(--color-muted);
  transition: transform var(--duration);
}
/* Without a meta text, the arrow sits on the right edge */
.dropdown-btn .dropdown-name + .icon {
  margin-left: auto;
}
.dropdown-btn[aria-expanded="true"] .icon {
  transform: rotate(180deg);
}
.dropdown-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  min-width: 17.5rem;
  max-height: 17.5rem;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-float);
}
.dropdown-list [role="option"] {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.dropdown-list .n {
  font-size: var(--text-md);
  color: var(--color-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dropdown-list .m {
  flex: none;
  font-size: var(--text-xs);
  color: var(--color-muted);
  white-space: nowrap;
}
.dropdown-list [role="option"].active {
  background: var(--color-field);
}
.dropdown-list [role="option"][aria-selected="true"] .n {
  font-weight: var(--weight-bold);
}

.segmented {
  position: relative;
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  border-radius: var(--radius-lg);
  background: var(--color-field);
}
/* The highlight slides between choices. segmented-motion.js sets --seg-x and --seg-w. */
.segmented::before {
  content: "";
  position: absolute;
  top: var(--space-1);
  bottom: var(--space-1);
  left: 0;
  width: 0;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-border);
  opacity: 0;
  transform: translateX(var(--seg-x, 0));
  width: var(--seg-w, 0);
  transition:
    transform 0.25s cubic-bezier(0.3, 0.7, 0.2, 1),
    width 0.25s cubic-bezier(0.3, 0.7, 0.2, 1);
}
.segmented[data-seg-ready]::before {
  opacity: 1;
}
.segmented.seg-still::before {
  transition: none;
}
.segmented button {
  position: relative;
  flex: 1;
  padding: 6px var(--space-2);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  font-size: var(--text-sm);
  color: var(--color-muted);
  transition: color 0.2s;
}
.segmented button[aria-pressed="true"] {
  color: var(--color-ink);
}
/* Without the script, fall back to a plain highlighted button */
.segmented:not([data-seg-ready]) button[aria-pressed="true"] {
  background: var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-border);
}

.option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: transparent;
  text-align: left;
  transition:
    border-color var(--duration),
    background-color var(--duration),
    transform var(--duration) ease-out;
}
.option:hover {
  background: var(--color-field);
}
.option[aria-pressed="true"] {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}
.option .icon {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--color-muted);
}
.option[aria-pressed="true"] .icon {
  color: var(--color-accent);
}
.option-title {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-ink);
}
.option-desc {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.check-row,
.radio-row {
  transform-origin: left center;
  transition: transform var(--duration) ease-out;
}
/* Press feedback: the box and its label dip together */
.check-row:not(:has(input:disabled)):active,
.radio-row:not(:has(input:disabled)):active {
  transform: scale(0.97);
}
.check-row {
  display: flex;
  align-items: flex-start; /* box lines up with the first line of a wrapping label */
  gap: var(--space-2);
  padding: var(--space-2) var(--space-1);
  cursor: pointer;
}
.check-row input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
  margin: calc((1lh - 1.125rem) / 2) 0 0; /* centre on the first text line */
  border: 1.5px solid var(--color-muted);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  transition:
    background-color 0.15s,
    border-color 0.15s,
    transform 0.15s;
}
.check-row input::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 15px;
  height: 15px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 15' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 7.8l2.8 2.8 5.2-6'/%3E%3C/svg%3E") center / 100% 100% no-repeat; /* always white, on the accent fill */
  clip-path: inset(0 100% 0 0);
}
.check-row input:checked {
  border-color: var(--color-accent);
  background: var(--color-accent);
}
.check-row input:checked::after {
  clip-path: inset(0);
  animation: check-draw 0.22s ease-out 0.05s backwards;
}
.check-row input:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
@keyframes check-draw {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .check-row:active,
  .radio-row:active {
    transform: none;
  }
  .segmented::before,
  .check-row input,
  .check-row input::after {
    transition: none;
    animation: none;
  }
}

/* ---------- slider ---------- */
/* Chunky pill track with a tinted fill, a large round thumb, the minimum on its left, the maximum on its right and the
   current value in a bubble above the thumb (the bubble floats, it does not take up space). Markup and behaviour: slider.js.
   The track is drawn on .slider-track::before so the thumb can sit centred in the pill's round end caps. */
.slider {
  --thumb: 24px;
  --track: 36px;
  --hit: max(var(--track), var(--thumb)); /* height of the whole control, so a thumb taller than the track is not clipped */
  --pad: max(0px, calc((var(--track) - var(--thumb)) / 2)); /* thumb centred in the end caps */
  --inset: 3px;
  --cap: calc(var(--track) / 2 - var(--inset));
  --tint: color-mix(in srgb, var(--color-accent) 28%, var(--color-field));
  --pct: 0;
  --fill: calc(var(--pad) + var(--thumb) / 2 + (100% - var(--pad) * 2 - var(--thumb)) * var(--pct));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--space-3);
}
/* Thin variation (.slider-thin): the same pill with the thumb inside it, just smaller, for secondary controls such as a preview width */
.slider-thin {
  --thumb: 10px;
  --track: 20px;
  --inset: 2px;
}
.slider-min,
.slider-max {
  font-size: var(--text-sm);
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.slider-track {
  position: relative;
  min-width: 0;
  height: var(--hit);
}
.slider-track::before {
  content: "";
  position: absolute;
  inset: calc((var(--hit) - var(--track)) / 2) 0;
  border-radius: var(--radius-full);
  /* The fill is inset in the track with round caps; the right one is centred on the thumb, so it shows as a ring past it */
  background:
    radial-gradient(circle at var(--fill) 50%, var(--tint) calc(var(--cap) - 0.5px), transparent var(--cap)),
    radial-gradient(circle at calc(var(--inset) + var(--cap)) 50%, var(--tint) calc(var(--cap) - 0.5px), transparent var(--cap)),
    linear-gradient(var(--tint), var(--tint)) calc(var(--inset) + var(--cap)) var(--inset) /
      max(0px, calc(var(--fill) - var(--inset) - var(--cap))) calc(100% - var(--inset) * 2) no-repeat,
    var(--color-field);
  box-shadow: inset 0 0 0 1px var(--color-border), inset 0 2px 4px rgba(0, 0, 0, 0.08);
}
.slider-value {
  position: absolute;
  bottom: calc(100% + 6px);
  left: var(--fill);
  z-index: 2;
  transform: translateX(-50%) translateY(6px) scale(0.9);
  opacity: 0;
  filter: blur(6px);
  /* Leaving: hold for a moment after release, then fade and blur away */
  transition: opacity 0.3s ease 0.5s, filter 0.3s ease 0.5s, transform 0.3s ease 0.5s;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-border), 0 2px 8px rgba(0, 0, 0, 0.12);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  color: var(--color-ink);
  white-space: nowrap;
  pointer-events: none;
}
/* The bubble shows while the thumb is held (or focused from the keyboard) and fades out after release */
.slider.is-active .slider-value,
.slider:has(input[type="range"]:focus-visible) .slider-value {
  transform: translateX(-50%);
  opacity: 1;
  filter: none;
  transition-duration: 0.15s;
  transition-delay: 0s;
}
.slider input[type="range"] {
  position: relative;
  z-index: 1;
  display: block;
  width: calc(100% - var(--pad) * 2);
  height: var(--hit);
  margin: 0 var(--pad);
  padding: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.slider input[type="range"]::-webkit-slider-runnable-track {
  height: var(--hit);
  background: transparent;
}
.slider input[type="range"]::-moz-range-track {
  height: var(--hit);
  background: transparent;
}
.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--thumb);
  height: var(--thumb);
  margin-top: calc((var(--hit) - var(--thumb)) / 2);
  border: 0;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}
.slider input[type="range"]::-moz-range-thumb {
  width: var(--thumb);
  height: var(--thumb);
  border: 0;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}
.slider input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.06);
}
.slider input[type="range"]:hover::-moz-range-thumb {
  transform: scale(1.06);
}
.slider input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(0.92);
}
.slider input[type="range"]:active::-moz-range-thumb {
  transform: scale(0.92);
}
.slider input[type="range"]:focus-visible {
  outline: none;
}
.slider input[type="range"]:focus-visible::-webkit-slider-thumb {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.slider input[type="range"]:focus-visible::-moz-range-thumb {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.slider input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
@media (prefers-reduced-motion: reduce) {
  .slider-value,
  .slider input[type="range"]::-webkit-slider-thumb,
  .slider input[type="range"]::-moz-range-thumb {
    transition: none;
  }
}

/* ---------- feedback ---------- */

/* ---------- radio buttons ---------- */

.radio-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-1);
  cursor: pointer;
}
.radio-row input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  border: 1.5px solid var(--color-muted);
  border-radius: var(--radius-full);
  background: transparent;
  cursor: pointer;
  transition:
    border-color 0.15s,
    transform 0.15s;
}
.radio-row input::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  transform: scale(0);
  transition: transform 0.18s cubic-bezier(0.3, 0.7, 0.2, 1);
}
.radio-row input:checked {
  border-color: var(--color-accent);
}
.radio-row input:checked::after {
  transform: scale(1);
}
.radio-row input:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.radio-row:has(input:disabled),
.radio-row input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.radio-row:has(.radio-hint) {
  align-items: flex-start;
}
.radio-row:has(.radio-hint) input {
  margin-top: 1px;
}
.radio-row .radio-hint {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-muted);
}

/* A set of radio buttons: <fieldset class="radio-group"><legend class="field-label">…</legend> .radio-row … */
.radio-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.radio-group legend {
  padding: 0;
}
.radio-group-inline {
  flex-direction: row;
  flex-wrap: wrap;
  column-gap: var(--space-4);
}
.radio-group-inline legend {
  width: 100%;
}
@media (prefers-reduced-motion: reduce) {
  .radio-row input,
  .radio-row input::after {
    transition: none;
  }
}

.link-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.link-list button {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 0;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  text-align: left;
  color: var(--color-ink);
}
.link-list button:last-child {
  border-bottom: 0;
}
.link-list button:hover {
  background: var(--color-field);
}
.link-list button span {
  flex: 1;
}
.link-list .icon {
  color: var(--color-muted);
}

.privacy-note,
.info-note {
  display: flex;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--color-muted);
}
.privacy-note,
.info-note {
  align-items: flex-start; /* icon stays beside the first line when the text wraps */
  text-align: left;
}
.privacy-note .icon,
.info-note .icon {
  width: 0.875rem;
  height: 0.875rem;
}
.privacy-note .icon,
.info-note .icon {
  margin-top: 0.15rem;
}

.progress {
  height: 0.375rem;
  border-radius: var(--radius-full);
  background: var(--color-field);
  overflow: hidden;
}
.progress > div {
  height: 100%;
  width: 0;
  background: var(--color-accent);
  transition: width 0.2s;
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: var(--space-6);
  transform: translate(-50%, 20px);
  padding: 9px var(--space-4);
  border-radius: var(--radius-full);
  background: var(--color-ink);
  color: var(--color-on-ink);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.center-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: 2.5rem;
  text-align: center;
}

.status-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
}
.status-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ---------- dropzone ---------- */

.dropzone-root {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.dropzone-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: clamp(3rem, 18vh, 12.5rem) var(--space-6) 2.5rem;
  text-align: center;
}
.dropzone-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.dropzone-copy h1 {
  font-size: var(--text-xl);
}
.dropzone-copy p {
  max-width: 28rem;
}
.dropzone-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin: var(--space-2) 0;
}
.drop-hint {
  margin-top: calc(var(--space-2) * -1);
}

/* ---------- directory pages ---------- */

.index-main {
  /* Same padding as the portfolio's main page */
  padding: 32px 32px 96px;
}
.index-main .lead {
  margin-top: var(--space-3);
  max-width: 40rem;
  font-size: var(--text-md);
  color: var(--color-muted);
}
/* Sits exactly where "Georges Raad" sits on the main page */
.tools-layout {
  display: grid;
  grid-template-columns: 0.3fr 1fr 1fr; /* same columns as the main page */
  gap: 24px;
}
.filters {
  grid-column: 1;
  grid-row: 1 / span 2; /* spans the list rows so it stays sticky beside them */
  position: sticky;
  top: 32px;
  align-self: start;
  width: 100%;
  max-width: 9rem; /* narrower than the column so the counts sit clear of the content */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0; /* spacing comes from each link's padding, as in the main page lists */
  font-size: 13px;
  line-height: 1.2;
}
/* Category colours: one per category, used by the filter dots and the tool icons */
[data-category="color"],
.filters a[data-filter="color"] { --cat: var(--cat-color); }
[data-category="pdf"],
.filters a[data-filter="pdf"] { --cat: var(--cat-pdf); }
[data-category="image"],
.filters a[data-filter="image"] { --cat: var(--cat-image); }
[data-category="miscellaneous"],
.filters a[data-filter="miscellaneous"] { --cat: var(--cat-misc); }
[data-category="text"],
.filters a[data-filter="text"] { --cat: var(--cat-text); }
[data-category="developer"],
.filters a[data-filter="developer"] { --cat: var(--cat-developer); }
.filters a {
  display: flex;
  align-items: center;
  gap: 12px;
  align-self: stretch;
  padding: 3px 0; /* same as the lists on the main page */
  color: var(--color-muted);
  text-decoration: none;
  transition: color var(--duration);
}
.filters a::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: -4px; /* 8px from the label with the 12px gap */
  border-radius: 50%;
  background: var(--cat, var(--color-muted));
  opacity: var(--cat-dot-opacity, 1);
}
.filters a[data-filter="all"]::before {
  --cat-dot-opacity: 0.45; /* neutral dot for "All tools" */
}
.filters .count {
  margin-left: auto; /* count on the right edge of the sidebar */
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}
.filters a:hover {
  color: var(--color-accent);
}
.filters a[aria-current] {
  color: var(--color-ink-hover); /* black in light mode, white in dark */
}
.tool-search {
  /* Lives in the top bar, between the breadcrumb and the page actions */
  flex: 0 1 240px;
  margin: -6px auto 0;
}
.tool-search .field {
  gap: var(--space-2);
  width: 100%;
}
.tool-search .field > .icon,
.tool-search .search-clear .icon {
  width: 0.875rem; /* 14px, to suit the smaller text */
  height: 0.875rem;
}
.tool-search .field > .icon {
  color: var(--color-muted);
  opacity: 0.55; /* same as the placeholder text */
}
.tool-search .search-clear .icon {
  color: var(--color-muted);
}
/* Same size as the breadcrumb next to it */
.tool-search input {
  font-size: var(--text-sm);
}
.tool-search input::-webkit-search-cancel-button {
  display: none;
}
.tool-search .search-clear {
  display: flex;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
}
.tool-search .search-clear[hidden] {
  display: none;
}
.tool-search .search-clear:hover {
  color: var(--color-accent);
}
.tool-empty {
  color: var(--color-muted);
  font-size: var(--text-md);
}
.tool-card[hidden] {
  display: none;
}
.tools-layout .tool-sections {
  grid-column: 2 / 4;
  transition: opacity 140ms ease, transform 140ms ease;
}
.tool-sections.is-switching {
  opacity: 0;
  transform: translateY(3px);
  transition-duration: 80ms;
}
/* Space only between sections that are both showing */
.tool-section:not([hidden]) ~ .tool-section:not([hidden]) {
  margin-top: var(--space-12);
}
.tool-section[hidden] {
  display: none;
}
.tool-section h2 {
  margin-bottom: var(--space-4);
  font-size: var(--text-lg);
}
/* Up to 1024px the filters sit on top as a row instead of in a sidebar */
@media (max-width: 1024px) {
  .tools-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
  }
  .tools-layout .tool-sections {
    grid-column: 1;
  }
  .filters {
    grid-column: 1;
    grid-row: 1;
    position: static;
    max-width: none;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0 20px;
    /* One swipeable row (dragged with a mouse in the page script); the scrollbar is hidden */
    overflow-x: auto;
    scrollbar-width: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
  }
  .filters::-webkit-scrollbar {
    display: none;
  }
  .filters.is-dragging {
    cursor: grabbing;
  }
  .filters a {
    flex-shrink: 0;
    white-space: nowrap;
    display: inline-flex;
    align-self: auto;
    gap: 6px;
  }
  .filters a::before {
    margin-right: 0;
  }
  .tools-layout .tool-sections {
    grid-column: 1;
  }
}

.page-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-12);
}
/* Pull the switch up so the breadcrumb text keeps its exact position */
.page-top .theme-switch,
.page-top .bookmark {
  margin-top: -6px;
}
.page-actions {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
/* Wide layout: use the same columns as the list below, so the search lines up with the cards */
@media (min-width: 1025px) {
  /* One grid for the whole page: the first column is as wide as its widest content (the breadcrumb), so the filters
     below share that width and their counts line up with the right edge of "Tools". */
  .index-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 48px;
    align-content: start;
  }
  .index-main > * {
    grid-column: 1 / -1;
  }
  .page-top,
  .tools-layout {
    display: grid;
    grid-template-columns: subgrid;
    gap: 24px 48px;
  }
  .filters {
    max-width: none;
  }
  .page-crumbs {
    white-space: nowrap;
  }
  .page-top .tool-search {
    justify-self: start;
    width: 100%;
    max-width: 280px;
    margin: -12px 0 0; /* centres the 40px field on the breadcrumb text */
  }
  .page-actions {
    grid-column: 3;
    justify-self: end;
  }
}
/* Stacked layout: make the space above the filters match the space below them */
@media (max-width: 1024px) {
  .page-top {
    margin-bottom: var(--space-6);
  }
}
/* Between the two: the search keeps the wide layout's place, left-aligned right after the breadcrumb */
@media (min-width: 801px) and (max-width: 1024px) {
  .page-top {
    display: grid;
    grid-template-columns: auto minmax(0, 280px) minmax(0, 1fr);
    gap: 24px;
  }
  .page-crumbs {
    white-space: nowrap;
  }
  .page-top .tool-search {
    justify-self: start;
    width: 100%;
    margin: -12px 0 0;
  }
  .page-actions {
    grid-column: 3;
    justify-self: end;
  }
}
/* Small screens: crumbs and actions share the first row, the search drops below at full width */
@media (max-width: 800px) {
  .page-top {
    flex-wrap: wrap;
    row-gap: var(--space-6);
  }
  .page-top .page-crumbs {
    flex: 1 1 auto;
  }
  .page-top .page-actions {
    order: 2;
  }
  .page-top .tool-search {
    order: 3;
    flex: 1 1 100%;
    margin: 0;
  }
}
.page-crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 1.2;
  color: var(--color-muted);
}
.page-crumbs a {
  color: var(--color-text);
  text-decoration: none;
  transition: color var(--duration);
}
.page-crumbs a:hover {
  color: var(--color-accent);
}
.index-main .privacy-note {
  margin-top: var(--space-4);
}
.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}
/* List columns by window width: 3 from 1440px, 2 from 800px, 1 below that */
@media (max-width: 1439px) {
  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 799px) {
  .tool-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
.tool-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: start; /* titles and descriptions start at the same height across a row of cards; extra height falls below */
  align-content: start;
  column-gap: var(--space-4);
  row-gap: var(--space-1);
  --icon-radius: var(--radius-md);
  padding: var(--space-4);
  border-radius: var(--radius-2xl);
  background: var(--color-surface);
  text-decoration: none;
  position: relative;
  isolation: isolate;
}
/* The hover colour fades in as a layer on top of the white card */
.tool-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--color-field-hover);
  opacity: 0;
  transition: opacity 280ms ease;
}
.tool-card:hover::before,
.tool-card:focus-visible::before {
  opacity: 1;
}
.tool-card .tool-icon {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--icon-radius);
  background: color-mix(in srgb, var(--cat, var(--color-accent)) 20%, var(--color-surface)); /* pastel tint of the category colour, set on the section */
  color: var(--cat, var(--color-accent));
}
.tool-card .tool-chevron {
  grid-column: 3;
  grid-row: 1 / 3;
  align-self: center;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--color-muted);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 280ms ease, transform 280ms ease;
}
.tool-card:hover .tool-chevron,
.tool-card:focus-visible .tool-chevron {
  opacity: 1;
  transform: translateX(0);
}
@media (prefers-reduced-motion: reduce) {
  .tool-card .tool-chevron {
    transform: none;
  }
}
.tool-card .tool-icon .icon {
  width: 1.25rem;
  height: 1.25rem;
}
.tool-card h3 {
  font-size: var(--text-md);
  font-weight: 500;
}
.tool-card p {
  color: color-mix(in srgb, var(--color-muted) 75%, var(--color-surface)); /* lighter than the muted text */
  font-size: var(--text-xs);
}

/* ---------- responsive ---------- */

@media (max-width: 800px) {
  .index-main,
  .topbar {
    padding: 18px;
  }
  .index-main {
    padding-bottom: 64px;
  }
}

@media (max-width: 860px) {
  :root {
    --page-padding: var(--space-4);
  }
  /* Narrow screens: the tool links drop to their own row under the breadcrumb */
  .topbar:has(.tool-tabs) {
    flex-wrap: wrap;
    row-gap: var(--space-8);
  }
  .topbar:has(.tool-tabs) .topbar-sep {
    display: none;
  }
  .topbar:has(.tool-tabs) .tool-tabs {
    order: 3;
    flex: 1 1 100%;
    margin-bottom: var(--space-2); /* one tighter gap under the tabs on every page */
  }
  .topbar:has(.tool-tabs) .tool-tabs > a:first-child {
    padding-left: 0;
  }
  /* File uploader pages keep their original space under the tabs (the tab gap above shrank by 24px) */
  .dropzone-empty {
    padding-top: calc(var(--space-12) + var(--space-6));
  }
}

/* iOS Safari zooms the page when an input under 16px takes focus */
@media (pointer: coarse) {
  .field input,
  select.select {
    font-size: 1rem;
  }
}

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

/* Code block (.code-block): read-only code in a scrollable, focusable box. Use <pre class="code-block" tabindex="0"><code>…</code></pre> */
.code-block {
  margin: 0;
  padding: var(--space-4);
  overflow: auto;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: var(--color-field);
  color: var(--color-ink);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  tab-size: 2;
  white-space: pre;
}
.code-block:hover {
  background: var(--color-field-hover);
}
.code-block:focus-visible {
  outline: none;
  border-color: var(--color-accent);
}

/* Ratio picker (.ratio-picker): tiles that show an aspect ratio as a shape with its label underneath. One is selected at a time.
   Set the shape's size with --rw and --rh (px). Add .ratio-shape-free for a dashed "any shape" outline.
     <div class="ratio-picker" role="group" aria-label="Aspect ratio">
       <button type="button" class="ratio-tile" aria-pressed="true"><span class="ratio-shape" style="--rw:18px;--rh:14px"></span><span class="ratio-label">4:3</span></button>
     </div> */
.ratio-picker {
  --ratio-gap: calc(var(--space-2) + 12px);
  display: flex;
  gap: var(--ratio-gap);
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.ratio-picker::-webkit-scrollbar {
  display: none;
}
.ratio-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-2);
  flex: none;
  min-width: 3.25rem;
  min-height: 3.5rem;
  padding: var(--space-2) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--color-ink);
  cursor: pointer;
  transition:
    background-color var(--duration),
    border-color var(--duration),
    color var(--duration),
    transform var(--duration) ease-out;
}
/* A vertical line, as tall as the tiles, sits in the gap between neighbouring tiles */
.ratio-tile {
  position: relative;
}
.ratio-tile + .ratio-tile::before {
  content: "";
  position: absolute;
  left: calc(var(--ratio-gap) / -2);
  top: 0;
  bottom: 0;
  width: 1px;
  background: color-mix(in srgb, var(--color-ink) 7%, transparent);
  pointer-events: none;
}
.ratio-shape {
  display: block;
  box-sizing: border-box;
  width: var(--rw, 18px);
  height: var(--rh, 18px);
  border: 1px solid currentColor;
  border-radius: 2px;
  margin-block: calc((var(--ratio-box, 18px) - var(--rh, 18px)) / 2); /* every shape sits in the same 18px-tall slot, so their middles line up */
}
.ratio-shape-free {
  border-style: dashed;
}
.ratio-label {
  font-size: var(--text-xs);
  line-height: 1;
  white-space: nowrap;
}
.ratio-tile:hover {
  background: var(--color-field);
}
.ratio-tile:active {
  transform: scale(0.95);
}
.ratio-tile:focus-visible {
  outline: none;
  border-color: var(--color-accent);
}
.ratio-tile[aria-pressed="true"] {
  color: var(--color-accent);
  background: var(--color-accent-soft);
}
.ratio-tile:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ratio-tile:disabled:hover {
  background: transparent;
}
.ratio-tile:disabled:active {
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .ratio-tile {
    transition-property: background-color, border-color, color;
  }
}
