:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #ffffff;
  --tone: #f2f2f2;
  --ink: #111111;
  --muted: #5f5f5f;
  --accent: #111111;
  --accent-ink: #ffffff;
  --accent-hover: #333333;
  --line: #e4e4e4;
  --ring: rgba(17, 17, 17, 0.16);
  --code-bg: #111111;
  --code-ink: #f2f2f2;
  --error: #b42318;
  --map-bg: #e6e6e6;
  --map-filter: grayscale(1) contrast(1.05);

  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --surface: #141414;
    --tone: #1f1f1f;
    --ink: #ededed;
    --muted: #a3a3a3;
    --accent: #ededed;
    --accent-ink: #0a0a0a;
    --accent-hover: #cfcfcf;
    --line: #2a2a2a;
    --ring: rgba(237, 237, 237, 0.2);
    --code-bg: #1a1a1a;
    --code-ink: #ededed;
    --error: #ff8a80;
    --map-bg: #1f1f1f;
    --map-filter: grayscale(1) invert(0.9) contrast(0.9);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--font);
}
img { display: block; max-width: 100%; height: auto; }
a { color: var(--ink); text-underline-offset: 0.18em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
code { font: 0.92em/1 var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* One column, like a project README. Side padding clears the notch in landscape. */
.top, main, .foot {
  max-width: 760px; margin: 0 auto;
  padding: 0 max(20px, env(safe-area-inset-right, 0px)) 0 max(20px, env(safe-area-inset-left, 0px));
}

/* Controls fire on tap without the double-tap delay, and long-press doesn't select their labels. */
button, .button, summary, .top nav a {
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}

.top { display: flex; justify-content: space-between; align-items: center; padding-top: 20px; padding-bottom: 20px; }
.name { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink); text-decoration: none; }
.name img { border-radius: 6px; }
.top nav { display: flex; gap: 20px; }
.top nav a { color: var(--ink); text-decoration: none; }

section { padding: 40px 0; }
section + section { border-top: 1px solid var(--line); }
section h2 { font-size: 1.375rem; margin-bottom: 12px; }
section p { margin: 0 0 16px; }

/* Converter */
.convert { padding-top: 32px; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.5rem); font-weight: 700; }
.lead { color: var(--muted); font-size: 1.125rem; margin: 10px 0 24px; max-width: 60ch; }

/* The input and its Paste button share one row. */
.field { display: flex; gap: 8px; }
#link {
  flex: 1; min-width: 0;
  -webkit-appearance: none; appearance: none;
  padding: 14px 16px;
  font: inherit; font-size: 1.0625rem;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px;
}
#link:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--ring); }

.examples { margin: 10px 0 0; color: var(--muted); font-size: 0.9375rem; }
.examples button {
  padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 0.18em;
}
#paste-btn { flex: none; }

.status { min-height: 1.6em; margin: 12px 0 0; color: var(--error); font-size: 0.9375rem; }

/* Guide for short links, which a page can't expand (CORS). */
.short-help { margin-top: 4px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.short-help[hidden] { display: none; }
.short-help-title { font-size: 1.25rem; margin-bottom: 8px; }
.short-help ol { margin: 12px 0 0; padding-left: 1.4em; }
.short-help li { margin-bottom: 14px; padding-left: 4px; }
.short-help li::marker { font-weight: 600; }
.short-help .fine { display: block; margin-top: 6px; }
.addr {
  display: flex; align-items: center; gap: 8px; margin-top: 8px; max-width: 100%;
  padding: 8px 12px; background: var(--tone); border-radius: 999px;
  font: 0.8125rem/1.3 var(--mono); color: var(--ink);
  outline: 2px solid var(--ink); outline-offset: 2px;
}
.addr-lock { font-size: 0.75rem; flex: none; }
.addr-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
kbd { font: 600 0.8125rem/1 var(--mono); padding: 2px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); }

.answer { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.answer[hidden] { display: none; }
.answer-map { position: relative; height: 200px; overflow: hidden; background: var(--map-bg); }
.answer-map[hidden] { display: none; }
.answer-map .tile { position: absolute; width: 256px; height: 256px; max-width: none; filter: var(--map-filter); }
.answer-pin {
  position: absolute; left: 50%; top: 50%; z-index: 1;
  width: 20px; height: 20px; margin: -10px 0 0 -10px;
  background: var(--accent); border: 4px solid var(--surface); border-radius: 50%;
}
.answer-body { padding: 20px; }
.answer-what { font-size: 1.5rem; overflow-wrap: anywhere; }
.answer-dest { margin: 4px 0 0; color: var(--muted); }
.answer-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.answer-more { margin-top: 16px; font-size: 0.9375rem; }
.answer-more summary { cursor: pointer; color: var(--muted); }
.answer-url { display: block; margin-top: 8px; padding: 10px 12px; background: var(--tone); border-radius: 6px; overflow-wrap: anywhere; font: 0.875rem/1.5 var(--mono); color: var(--ink); text-decoration: none; }
.answer-note, .answer-credit { margin: 8px 0 0; font-size: 0.8125rem; color: var(--muted); }
.another { display: none; }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px;
  font: 600 0.9375rem/1 var(--font);
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent); border-radius: 8px;
  text-decoration: none; cursor: pointer;
  transition: background-color 150ms ease, transform 120ms var(--ease-out);
}
.button-quiet { background: var(--surface); color: var(--ink); border-color: var(--line); }
.button:active { transform: scale(0.97); background: var(--accent-hover); border-color: var(--accent-hover); }
.button-quiet:active { background: var(--tone); border-color: var(--line); }

@media (hover: hover) and (pointer: fine) {
  .top nav a:hover { color: var(--accent); }
  .examples button:hover { color: var(--muted); }
  .button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
  .button-quiet:hover { background: var(--tone); border-color: var(--line); }
}

/* Fingers: example links become tappable chips, answer buttons share the row. */
@media (pointer: coarse) {
  .examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .examples button {
    min-height: 40px; padding: 0 14px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
    color: var(--ink); text-decoration: none;
  }
  .examples button:active { background: var(--tone); }
  .examples .sep { display: none; }
  .faq summary { padding: 6px 0; }
}
@media (max-width: 480px) {
  .answer-actions .button { flex: 1 1 auto; }
  .answer-map { height: 170px; }
  .focused .answer-actions .button { min-height: 52px; font-size: 1rem; }
}
.stars:not(:empty)::before { content: "·"; margin: 0 6px; color: var(--muted); }
.top nav .star-link { font-weight: 600; }

/* A quiet ask after the converter has helped; dismissible and remembered. */
.star-ask {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 12px 0 0; padding: 10px 6px 10px 16px;
  background: var(--tone); border-radius: 8px; font-size: 0.9375rem;
}
.star-ask[hidden] { display: none; }
.star-ask a { font-weight: 600; }
.star-ask-close {
  flex: none; width: 36px; height: 36px; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.star-ask-close:active { background: var(--line); }


/* Code */
pre {
  margin: 0 0 12px; padding: 14px 16px;
  background: var(--code-bg); color: var(--code-ink); border-radius: 8px;
  overflow-x: auto;
}
pre code { font-size: 0.875rem; line-height: 1.6; }
pre + .button { margin-top: 8px; }
.fine { margin: 10px 0 0; font-size: 0.875rem; color: var(--muted); }
.fine a { color: var(--muted); }

/* FAQ */
.faq details { border-bottom: 1px solid var(--line); padding: 14px 0; }
.faq details:first-of-type { border-top: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 10px 0 0; color: var(--muted); }

.foot { padding-bottom: max(40px, env(safe-area-inset-bottom, 0px)); color: var(--muted); font-size: 0.875rem; }
.foot p { margin: 0; padding-top: 24px; border-top: 1px solid var(--line); }
.foot a { color: var(--muted); }

/* Short landscape screens (phones sideways): tighter rhythm, map beside the answer so the actions stay on screen. */
@media (orientation: landscape) and (max-height: 520px) {
  .top { padding-top: 12px; padding-bottom: 12px; }
  .convert { padding-top: 8px; }
  section { padding: 28px 0; }
  .lead { margin-bottom: 16px; }
  .answer:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
  .answer:has(.answer-map[hidden]) { grid-template-columns: 1fr; }
  .answer-map { height: auto; min-height: 170px; }
  .answer-body { padding: 16px 20px; }
  .answer-actions { margin-top: 12px; }
  .focused .convert { padding-top: 12px; }
}

/* Opened from a link (?url=): only the answer */
.focused .top, .focused h1, .focused .lead, .focused .field, .focused .examples,
.focused main > section:not(.convert), .focused .foot { display: none; }
.focused .convert { padding-top: 24px; }
.focused .another { display: block; margin: 16px 0 0; }

/* ---------- Motion: short, quiet, and off for reduced motion ---------- */
@view-transition { navigation: auto; }

.faq summary, .answer-more summary, .short-help summary { list-style: none; }
.faq summary::-webkit-details-marker, .answer-more summary::-webkit-details-marker { display: none; }
.faq summary { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.faq summary::after, .answer-more summary::before {
  content: ""; flex: none; width: 7px; height: 7px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg); transition: transform 200ms var(--ease-out);
}
.answer-more summary { display: inline-flex; align-items: center; gap: 8px; }
.answer-more summary::before { transform: rotate(-45deg); }
.faq details[open] summary::after { transform: rotate(-135deg); }
.answer-more[open] summary::before { transform: rotate(45deg); }

a { transition: color 150ms ease, text-decoration-color 150ms ease; }

@media (prefers-reduced-motion: no-preference) {
  /* First paint: title, intro and field settle in, once. */
  .js .convert > :is(h1, .lead, .field, .examples, .button) { animation: rise 520ms var(--ease-out) both; }
  .js .convert > .lead { animation-delay: 60ms; }
  .js .convert > :is(.field, .button) { animation-delay: 120ms; }
  .js .convert > .examples { animation-delay: 170ms; }

  /* Sections below the fold, once, as they scroll in (motion.js). */
  .reveal { opacity: 0; transform: translateY(14px); transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out); }
  .reveal.is-in { opacity: 1; transform: none; }

  /* Things that appear in answer to the visitor. */
  .answer.arrive, .short-help:not([hidden]), .star-ask:not([hidden]) { animation: rise 320ms var(--ease-out); }
  .status:not(:empty) { animation: fade 200ms ease; }
  .answer-map .tile { animation: fade 400ms ease; }
  .answer.arrive .answer-pin { animation: drop 420ms 120ms var(--ease-out) both; }
  details[open] > :not(summary) { animation: rise 240ms var(--ease-out); }
  .button.done { animation: pop 260ms var(--ease-out); }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes drop { from { opacity: 0; transform: translateY(-14px); } }
@keyframes pop { 50% { transform: scale(1.04); } }
