:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --border: #e2dfd8;
  --text: #1d1b18;
  --muted: #6b665d;
  --accent: #e4572e;
  --accent-hover: #c9451f;
  --accent-soft: #fde8e1;
  --success: #1e7a46;
  --success-soft: #e1f3e8;
  --danger: #b3261e;
  --danger-soft: #fbe3e1;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 2px 8px rgb(0 0 0 / 0.04);
  --shadow-lg: 0 2px 6px rgb(0 0 0 / 0.06), 0 12px 32px rgb(0 0 0 / 0.08);
  --ring: color-mix(in srgb, var(--accent) 28%, transparent);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #211f1c;
    --surface-2: #2b2925;
    --border: #3a3732;
    --text: #f1eee8;
    --muted: #a39d92;
    --accent: #ff7a50;
    --accent-hover: #ff936f;
    --accent-soft: #3d241b;
    --success: #6fd49a;
    --success-soft: #1d3326;
    --danger: #ff8a80;
    --danger-soft: #3d1f1d;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 2px 6px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}

/* Flag emoji only (unicode-range), so they look the same everywhere, including Windows,
   which has no flag emoji. Twemoji art, CC-BY 4.0: see lib/flags/LICENSE.md. */
@font-face {
  font-family: "Twemoji Country Flags";
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  src: url("../lib/flags/TwemojiCountryFlags.woff2") format("woff2");
  font-display: swap;
}

* { box-sizing: border-box; }

/* Icons (src/ui-icons.js): inline SVG, sized by the font size, coloured by the text colour. */
.ico { flex: none; vertical-align: -0.15em; }
/* Tool icon: accent glyph on a soft rounded square. */
.tile {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2em;
  height: 2em;
  border-radius: 0.6em;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 16px;
}
.tile .ico { width: 1.2em; height: 1.2em; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Twemoji Country Flags", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2 { line-height: 1.25; margin: 0 0 4px; }
h1 { font-size: 26px; letter-spacing: -0.015em; }
h2 { font-size: 18px; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); }
[hidden] { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 3px 8px color-mix(in srgb, var(--accent) 22%, transparent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 30px; padding: 0 12px; font-size: 13px; }
/* The one main action of a tool (Compress, Merge & download, Save PDF…). */
.btn.primary.big, .tool-body .actions:not(dialog .actions) .btn.primary { min-height: 46px; padding: 0 26px; border-radius: 10px; font-size: 15px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

input.text, input.num, select {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input.text:hover, input.num:hover, select:hover { border-color: color-mix(in srgb, var(--muted) 45%, var(--border)); }
input.text:focus, input.num:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
/* Dropdowns: own chevron with room for it, so long names never run under the arrow. */
select {
  padding-inline-end: 32px;
  appearance: none;
  cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center;
}
select:dir(rtl) { background-position: left 11px center; }
input.text { min-width: 220px; }
input.num { width: 100px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; flex: none; cursor: pointer; }
label:has(> input[type="checkbox"]) { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }

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

/* "Buy us a coffee": a warm button with a light sweep that glides across it now and then. */
.shine {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #ff9a5a, var(--accent));
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 45%, transparent);
}
.shine::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 -60%;
  z-index: -1;
  width: 40%;
  background: linear-gradient(105deg, transparent, rgb(255 255 255 / 0.55), transparent);
  transform: skewX(-20deg);
  animation: shine 3.6s ease-in-out infinite;
}
.shine:hover { filter: brightness(1.06); }
@keyframes shine {
  0%, 55% { left: -60%; }
  100% { left: 130%; }
}
@media (prefers-reduced-motion: reduce) { .shine::after { animation: none; } }
