:root {
  color-scheme: light dark;
  --bg: #f5f6f9;
  --surface: #ffffff;
  --ink: #181c26;
  --muted: #4e5566;
  --line: #d4d8e2;
  --accent: #3546a8;
  --accent-ink: #ffffff;
  --button-bg: #1e2433;
  --button-ink: #f4f6fb;
  --warn-bg: #fdf1d3;
  --code-bg: #eceff5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141a;
    --surface: #1b1e27;
    --ink: #e9ecf3;
    --muted: #a9b0c0;
    --line: #343949;
    --accent: #a9b6ff;
    --accent-ink: #12141a;
    --button-bg: #e9ecf3;
    --button-ink: #12141a;
    --warn-bg: #3d3216;
    --code-bg: #262a36;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

a { color: var(--accent); }
img { max-width: 100%; height: auto; }
textarea.fallback { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }
.site-header { padding: 16px 0; }
.logo { color: var(--ink); font-weight: 750; text-decoration: none; display: inline-flex; gap: 8px; align-items: center; min-height: 44px; }

h1 { font-size: clamp(28px, 6vw, 42px); line-height: 1.12; letter-spacing: -0.02em; margin: 8px 0 12px; }
h2 { font-size: 23px; line-height: 1.2; margin: 40px 0 10px; }
h3 { font-size: 18px; margin: 24px 0 4px; }
.lead { color: var(--muted); max-width: 66ch; }
.lead p { margin: 0 0 10px; }
.small { font-size: 15px; color: var(--muted); margin: 0; }

/* Order: desktop order is the HTML order; phones move the phone block first (F4). */
.flow { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.flow > * { min-width: 0; }
.for-computers { display: none; margin: 0; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 14px; }
@media (pointer: coarse) and (max-width: 767px) {
  .phone-block { order: -1; }
  .for-computers { display: block; }
}
.ios .phone-block { order: -1; }
.ios .for-computers { display: block; }

/* Tool */
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: grid; gap: 14px; min-width: 0; }
.settings { display: grid; gap: 4px; min-width: 0; }
legend { font-size: 15px; font-weight: 600; }
.group { border: 0; margin: 0; padding: 0; min-width: 0; }
.group.inline { display: flex; flex-wrap: wrap; gap: 0 20px; }
.group.inline legend { width: 100%; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; min-width: 0; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); margin: 0; }
.check label { overflow-wrap: anywhere; }

.button-row { display: flex; }
.bookmarklet {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 28px;
  border-radius: 999px; background: var(--button-bg); color: var(--button-ink); font-size: 19px; font-weight: 750;
  text-decoration: none; cursor: grab; border: 2px dashed transparent;
}
.bookmarklet:hover { border-color: var(--accent); }
.bookmarklet:active { cursor: grabbing; }
.hint { margin: 0; min-height: 0; font-weight: 600; }
.warning { background: var(--warn-bg); padding: 8px 10px; border-radius: 8px; margin: 0; font-size: 15px; }
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { margin: 6px 0; }
.steps .sub { font-size: 15px; color: var(--muted); padding-left: 18px; }
.copy { display: grid; gap: 8px; min-width: 0; border-top: 1px solid var(--line); padding-top: 12px; }

.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px;
  border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none;
}
.button.secondary { background: transparent; color: var(--accent); border: 2px solid var(--accent); }
.button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
a:focus-visible, input:focus-visible, button:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.copy-row { display: flex; flex-wrap: wrap; gap: 10px; }
textarea.fallback {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink);
  font-size: 13px; resize: vertical; white-space: pre-wrap; word-break: break-all;
}

/* F2 preview: the same filter as the bookmarklet, scoped to the sample block. */
.try h2 { margin-top: 12px; }
.sample {
  --dim-invert: 0.92;
  --dim-contrast: 1.19;
  background: #ffffff; color: #202124; border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 12px;
}
.sample p { margin: 0 0 10px; }
.sample-heading { font-size: 21px; font-weight: 700; }
.sample-img { display: block; border-radius: 4px; }
.sample.is-dark { filter: invert(var(--dim-invert)) hue-rotate(180deg); }
.sample.is-dark.keep-images .sample-img { filter: invert(1) hue-rotate(180deg) contrast(var(--dim-contrast)); }

.phone-block { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 4px 16px; }
.phone-block h2 { margin-top: 12px; }

/* Sheets demo: plain HTML cells and bars; the dark copy uses the Dark filter. */
.demo { display: grid; gap: 16px; margin: 16px 0; }
.demo-pane { margin: 0; min-width: 0; }
.demo-pane figcaption { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.sheet { background: #ffffff; color: #202124; border: 1px solid #c7ccd6; border-radius: 6px; padding: 10px; display: grid; gap: 10px; }
.sheet table { border-collapse: collapse; width: 100%; font-size: 14px; }
.sheet td { border: 1px solid #dadce0; padding: 4px 8px; }
.sheet-head td { background: #fce8b2; font-weight: 700; }
.cell-up { background: #b7e1cd; }
.cell-down { background: #f4c7c3; }
.chart { display: flex; align-items: flex-end; gap: 12px; height: 80px; padding: 0 8px; border-bottom: 2px solid #9aa0a6; }
.bar { flex: 1; background: #4285f4; border-radius: 3px 3px 0 0; }
.bar-1 { height: 65%; }
.bar-2 { height: 51%; }
.bar-3 { height: 100%; }
.bar-4 { height: 88%; }
.demo-dark { filter: invert(0.92) hue-rotate(180deg); }

/* Text pages */
ul, ol { padding-left: 22px; }
li { margin: 6px 0; }
.legal { max-width: 760px; }

.site-footer { margin-top: 56px; padding: 20px 0 32px; border-top: 1px solid var(--line); }
.footer-row { display: grid; gap: 12px; }
.footer-note { font-size: 14px; color: var(--muted); margin: 0; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.site-footer nav a { min-height: 44px; display: inline-flex; align-items: center; }

@media (min-width: 720px) {
  .tool { padding: 24px; }
  .demo { grid-template-columns: 1fr 1fr; }
}
