:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e3e3df;
  --accent: #2b59ff;
  --accent-text: #ffffff;
  --drop: #eef2ff;
  --down: #13804b;
  --down-bg: #e3f5ea;
  --up: #a35a00;
  --up-bg: #fbefdc;
  --error: #c62828;
  --radius: 12px;
}

/* Dark by system setting, unless an embed forces light; or forced dark via data-theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414;
    --surface: #1e1e1e;
    --text: #ececec;
    --muted: #9a9a9a;
    --border: #2e2e2e;
    --accent: #6d8bff;
    --accent-text: #0b0b0b;
    --drop: #1c2238;
    --down: #5fd394;
    --down-bg: #17301f;
    --up: #f0b45c;
    --up-bg: #33260f;
    --error: #ff7b7b;
  }
}
:root[data-theme="dark"] {
  --bg: #141414;
  --surface: #1e1e1e;
  --text: #ececec;
  --muted: #9a9a9a;
  --border: #2e2e2e;
  --accent: #6d8bff;
  --accent-text: #0b0b0b;
  --drop: #1c2238;
  --down: #5fd394;
  --down-bg: #17301f;
  --up: #f0b45c;
  --up-bg: #33260f;
  --error: #ff7b7b;
}

:root { color-scheme: light dark; accent-color: var(--accent); }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

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

a { color: var(--accent); }

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

header.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 40px;
}

header.site a.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

h2, h3 { font-size: 1rem; margin: 0 0 12px; }
h2.category { font-size: 1.35rem; letter-spacing: -0.01em; margin: 40px 0 16px; }
h2.category[hidden] { display: none; }

.lede { color: var(--muted); margin: 0 0 32px; }

/* ---------- Homepage ---------- */
.search {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  margin: 0 0 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.group { margin: 0 0 28px; }
.group[hidden] { display: none; }

.chips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chips li[hidden] { display: none; }

.chips a {
  display: inline-block;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  transition: border-color 0.15s;
}
.chips .arrow { color: var(--muted); font-weight: 400; }

.empty { color: var(--muted); }

/* ---------- Converter ---------- */
.notice {
  padding: 12px 14px;
  margin: 0 0 16px;
  border-radius: var(--radius);
  background: var(--up-bg);
  color: var(--up);
  font-size: 0.92rem;
}
.notice[hidden] { display: none; }

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 220px;
  padding: 24px;
  text-align: center;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop.over, .drop:focus-visible { border-color: var(--accent); background: var(--drop); outline: none; }
.drop strong { font-size: 1.1rem; }
.drop span { color: var(--muted); font-size: 0.9rem; }
.drop input { display: none; }

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.options:empty { display: none; }
.options label, .options fieldset { display: inline-flex; align-items: center; gap: 8px; }
.options fieldset { border: 0; padding: 0; margin: 0; flex-wrap: wrap; }
.options legend { float: inline-start; margin-inline-end: 4px; }
.options input[type="range"] { width: 120px; }
.options input[type="color"] {
  width: 32px; height: 24px; padding: 0;
  border: 1px solid var(--border); border-radius: 4px; background: none;
}
.options select {
  font: inherit;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: space-between;
  align-items: center;
  margin: 28px 0 12px;
  font-size: 0.92rem;
}
.toolbar[hidden] { display: none; }
.toolbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }

button, .btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button[hidden] { display: none; }
button:disabled { opacity: 0.6; cursor: progress; }

button.primary, .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.results { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }

.results li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.results img, .results .thumb {
  width: 48px; height: 48px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
  background: repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0 / 12px 12px;
}
.results .thumb { background: var(--border); }
.results .thumb.label {
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em; color: var(--accent);
  background: var(--drop);
}
.results .files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.results .files a {
  font-size: 0.82rem; font-weight: 600; text-decoration: none;
  padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px;
}

.results .meta { flex: 1; min-width: 0; }
.results .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .size { color: var(--muted); font-size: 0.85rem; }
.results li.failed .size { color: var(--error); }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.down { color: var(--down); background: var(--down-bg); }
.badge.up { color: var(--up); background: var(--up-bg); }
.badge.same { color: var(--muted); background: var(--border); }

.note { margin-top: 40px; color: var(--muted); font-size: 0.9rem; }
.note p { margin: 0 0 6px; }

.related { margin-top: 40px; }
.related .group { margin-bottom: 24px; }

@media (max-width: 480px) {
  .results li { flex-wrap: wrap; }
  .results .meta { flex-basis: calc(100% - 60px); }
  .results li .btn { width: 100%; text-align: center; }
}

/* ---------- Page content (pSEO sections) ---------- */
.content { margin-top: 48px; }
.content h2 { font-size: 1.15rem; margin: 36px 0 12px; letter-spacing: -0.01em; }
.content p, .content li { color: var(--text); }
.points, .steps { margin: 0; padding-inline-start: 1.25em; display: grid; gap: 8px; }
.points li::marker { color: var(--accent); }
table.facts { width: 100%; border-collapse: collapse; font-size: 0.92rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.facts th, table.facts td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: top; }
table.facts tbody tr:last-child th, table.facts tbody tr:last-child td { border-bottom: 0; }
table.facts thead th { background: var(--drop); }
table.facts tbody th { color: var(--muted); font-weight: 500; width: 34%; }
details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px; }
details summary { cursor: pointer; font-weight: 600; }
details p { margin: 10px 0 2px; color: var(--muted); }
label.target { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-weight: 600; }
label.target select { font: inherit; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
[data-for][hidden] { display: none !important; }

footer.site { margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.88rem; }
footer.site p { margin: 0 0 8px; }
footer.site a { color: var(--muted); }
footer.site strong { color: var(--text); font-weight: 600; }
footer.site .langs { display: flex; flex-wrap: wrap; gap: 4px 14px; }
footer.site .legal { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; }
.content.legal { margin-top: 0; max-width: 46rem; }
.content.legal h1 { margin-bottom: 8px; }
.content.legal li { margin-bottom: 6px; }

@media (max-width: 480px) {
  table.facts th, table.facts td { padding: 8px; font-size: 0.85rem; }
}

/* ---------- Homepage drop-anything ---------- */
.drop-home { min-height: 180px; margin-bottom: 16px; }
.choose { display: grid; gap: 12px; margin: 0 0 8px; }
.choose[hidden] { display: none; }
.choose-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.choose .detected { margin: 0 0 10px; font-weight: 600; }
.choose .targets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.choose .targets > span { color: var(--muted); font-size: 0.9rem; margin-inline-end: 4px; }
.target-btn { border-radius: 999px; padding: 7px 14px; }
.target-btn.done { background: var(--drop); border-color: var(--accent); }
.choose .more { text-decoration: none; color: var(--muted); font-size: 0.9rem; margin-inline: -4px 6px; }
.choose .unsupported { margin: 0; color: var(--muted); font-size: 0.9rem; }
.search { margin-top: 32px; }

/* ---------- embeds ---------- */
body.embed { background: var(--bg); }
:root[data-bg="transparent"] body.embed { background: transparent; }
.embed-wrap { padding: 16px; }
.embed-head { font-weight: 600; font-size: 1.05rem; margin: 0 0 12px; }
:root[data-notitle] .embed-head { display: none; }
.embed .drop { padding: 28px 16px; min-height: 0; }
.embed .drop-home { min-height: 140px; }
.embed .options { margin-top: 12px; }
.embed-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin: 14px 0 0; font-size: 0.8rem; color: var(--muted); }
.embed-foot a { color: var(--muted); }

/* ---------- embed builder ---------- */
.builder { display: grid; gap: 16px; }
.builder .controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.builder .controls label { display: flex; gap: 8px; align-items: center; }
.builder iframe { width: 100%; height: 420px; border: 1px dashed var(--border); border-radius: var(--radius); background: transparent; }
.builder textarea { width: 100%; min-height: 150px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); resize: vertical; }
.builder .copy-row { display: flex; gap: 12px; align-items: center; }

/* ---------- mobile pass (≤480px; desktop rules above stay untouched) ---------- */
@media (max-width: 480px) {
  /* Chip lists scroll sideways instead of stacking dozens of rows; long lists use two rows. */
  .chips {
    display: grid; grid-auto-flow: column; grid-auto-columns: max-content; grid-template-rows: auto;
    gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
    margin: 0 -16px; padding: 2px 16px 6px; scroll-padding-inline: 16px; scrollbar-width: none;
  }
  .chips:has(> li:nth-child(7)) { grid-template-rows: repeat(2, auto); }
  .chips::-webkit-scrollbar { display: none; }
  .chips li { scroll-snap-align: start; }
  .chips a { display: block; line-height: 26px; padding: 8px 14px; } /* 44px tall */

  .drop { min-height: 160px; }
  .drop-home { min-height: 140px; }

  /* 44px tap targets; 16px text in form controls so iOS doesn't zoom on focus. */
  button, .btn { min-height: 44px; }
  .options select, label.target select, .builder select, .search { font-size: 16px; min-height: 44px; }
  .options select { padding: 8px 10px; }
  .builder .controls { gap: 12px 16px; }
  .builder .controls label { flex-wrap: wrap; }
  .builder select { max-width: 100%; }

  /* Primary actions span the width. */
  .toolbar .actions { width: 100%; }
  .toolbar .actions button { flex: 1; }
  .builder .copy-row button { flex: 1; }

  header.site a:not(.brand) { padding: 10px 0; }
  footer.site { margin-top: 48px; }
  footer.site .langs a, footer.site .legal a { display: inline-block; padding: 6px 0; }
}

/* ---------- native feel on touch screens ---------- */
html {
  -webkit-tap-highlight-color: transparent; /* no gray flash; :active below gives the feedback */
  -webkit-text-size-adjust: 100%;           /* no font inflation in landscape */
}

/* Hover only where a precise pointer can hover; on touch a tap would leave it stuck on. */
@media (hover: hover) and (pointer: fine) {
  .chips a:hover, .results .files a:hover, .target-btn:hover { border-color: var(--accent); }
  .drop:hover { border-color: var(--accent); background: var(--drop); }
  .choose .more:hover { color: var(--accent); }
}

/* Taps fire immediately (no double-tap-zoom wait) and controls don't select their labels. */
button, .btn, a, label, select, summary, .drop, [role="button"] { touch-action: manipulation; }
button, .btn, .chips a, .target-btn, .drop, summary, .results .files a {
  -webkit-user-select: none;
  user-select: none;
}

/* Press feedback the moment a finger lands, on every input type. */
button, .btn, .chips a, .results .files a { transition: transform 120ms cubic-bezier(0.23, 1, 0.32, 1), border-color 0.15s, background 0.15s; }
.drop:active { border-color: var(--accent); background: var(--drop); }
.chips a:active, .results .files a:active, .target-btn:active { border-color: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  button:active:not(:disabled), .btn:active, .chips a:active, .results .files a:active { transform: scale(0.97); }
}

/* iOS zooms into any field under 16px on focus (tablets included), so touch screens get 16px. */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px; }
}
