/* WriteKeys */

:root {
  --bg: #ffffff;
  --bg-soft: #f4f6f7;
  --surface: #ffffff;
  --border: #d8dee3;
  --border-strong: #b4bec7;
  --text: #16202a;
  --muted: #56636f;
  --accent: #0a6b66;
  --accent-hover: #085751;
  --accent-soft: #e4f2f0;
  --accent-ink: #ffffff;
  --code-bg: #f1f4f6;
  --shadow: 0 1px 2px rgb(16 32 40 / 6%), 0 6px 24px rgb(16 32 40 / 6%);
  --radius: 12px;
  --font:
    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --mono:
    ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  /* Always the light theme, even when the device is set to dark mode. */
  color-scheme: light;
}

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

/* Elements hidden from script stay hidden even when a class sets display. */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

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

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

.wrap {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: 20px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 10;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.skip:focus {
  top: 12px;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
}

/* Header ------------------------------------------------------------------ */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
}

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

.brand:hover {
  color: var(--text);
}

.brand-mark {
  width: 30px;
  height: 30px;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-size: 14.5px;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--text);
}

.site-nav a[aria-current="page"] {
  font-weight: 600;
}

/* Tool -------------------------------------------------------------------- */

.tool {
  padding-block: 22px 8px;
}

/* Under the text box. */
.intro {
  margin-top: 24px;
}

.intro h1 {
  margin: 0;
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.lede {
  max-width: 72ch;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1.04rem;
}

.private-note {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 0 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.private-note .icon {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--accent);
}

.editor-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* The buttons stay at the top of the screen while the page scrolls, so part of
   a long note can be selected and changed without scrolling back up. */
.editor-controls {
  position: sticky;
  top: 0;
  z-index: 5;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  background: var(--surface);
}

/* Groups sit side by side, each with a small label above its buttons. */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 22px;
  padding: 12px 16px;
}

.group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.group-label {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

button {
  font: inherit;
}

.act {
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition:
    border-color 0.12s,
    background-color 0.12s;
}

.act:hover {
  border-color: var(--border-strong);
  background: var(--bg-soft);
}

.act:active {
  transform: translateY(1px);
}

.act.is-featured {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}

/* Icon buttons: a drawing or a few letters, with the name in a tooltip. */
.act.is-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  box-shadow: 0px 3px 2px;
}

.act .icon {
  width: 18px;
  height: 18px;
}

.glyph {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.act.is-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.act.is-toggle[aria-pressed="false"] .glyph {
  color: var(--muted);
  text-decoration: line-through;
}

.util.is-icon {
  justify-content: center;
  width: 36px;
  padding: 0;
  box-shadow: 0px 3px 2px;
}

/* Tooltips. Made only while hovered or focused, so an invisible tooltip never
   makes the sideways-scrolling toolbar on phones taller. */
[data-tip] {
  position: relative;
}

[data-tip]:focus-visible::after,
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  z-index: 30;
  width: max-content;
  max-width: 240px;
  padding: 6px 9px;
  border-radius: 6px;
  background: #1b2530;
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: normal;
  text-align: left;
  text-decoration: none;
  text-transform: none;
  white-space: pre-line;
  pointer-events: none;
  transform: translateX(-50%);
  animation: tip-in 0.12s ease-out 0.2s both;
}

[data-tip][data-hint]:focus-visible::after,
[data-tip][data-hint]:hover::after {
  content: attr(data-tip) "\A" attr(data-hint);
}

/* Buttons near the right edge open their tooltip toward the left. */
.utils [data-tip]:focus-visible::after,
.utils [data-tip]:hover::after {
  right: 0;
  left: auto;
  transform: none;
}

@keyframes tip-in {
  from {
    opacity: 0;
  }
}

.keep {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 4px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.keep input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

.editor-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 12px 8px 16px;
  border-block: 1px solid var(--border);
  background: var(--bg-soft);
}

.scope {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.scope.is-selection {
  color: var(--accent);
  font-weight: 600;
}

.utils {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.util {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.util .icon {
  width: 16px;
  height: 16px;
}

.util:hover:not(:disabled) {
  border-color: var(--border-strong);
}

/* Fade the contents, not the button: opacity on the button would trap its
   tooltip underneath the text box. */
.util:disabled {
  cursor: default;
}

.util:disabled > * {
  opacity: 0.45;
}

.util.is-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.util.is-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.util.is-done {
  background: var(--accent-hover);
}

.util.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Find and replace ------------------------------------------------------- */

.find-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.find-field {
  position: relative;
  flex: 0 1 220px;
  min-width: 150px;
}

.find-field input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
}

#find-input {
  padding-right: 86px;
}

.find-count {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 12.5px;
  pointer-events: none;
}

.find-count.is-none {
  color: #a3261b;
}

.find-bar .icon-btn {
  width: 32px;
  height: 32px;
}

.find-bar .util {
  height: 34px;
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.find-close {
  margin-left: auto;
}

/* The text box ------------------------------------------------------------ */

.editor-wrap {
  position: relative;
  background: var(--surface);
}

/* Shared by the text box and the highlight layer behind it, so both wrap lines
   at exactly the same places. */
.editor-text {
  margin: 0;
  padding: 18px 20px;
  border: 0;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: normal;
  tab-size: 8;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  scrollbar-gutter: stable;
}

.editor {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: clamp(340px, 70vh, 960px);
  min-height: 220px;
  background: transparent;
  color: var(--text);
  resize: vertical;
}

.editor-highlights {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  color: transparent;
  pointer-events: none;
}

.editor-highlights mark {
  border-radius: 2px;
  background: transparent;
  color: transparent;
}

/* Highlighter yellow behind words still to fill in. */
.editor-highlights mark.mark {
  background: #fff176;
}

/* Find matches are blue, so yellow always means "fill this in". */
.editor-highlights mark.find {
  background: #cfe2ff;
}

.editor-highlights mark.find.is-current {
  background: #9cc3ff;
  box-shadow: 0 0 0 1px #3b7ddd;
}

/* Spell check: a red wavy line under words that may be misspelled. The letters
   in this layer are invisible, so the line has its own color. */
.editor-highlights mark.spell {
  text-decoration: underline wavy #c4321f;
  text-decoration-skip-ink: none;
  text-underline-offset: 3px;
}

.marks-summary {
  color: #7a5c00;
  font-weight: 600;
}

.spell-summary {
  color: #a3261b;
  font-weight: 600;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.field-head label {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

/* A hidden copy of the text, used to find where the cursor's word sits. */
.editor-mirror {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
}

/* Autocomplete -------------------------------------------------------------- */

.ac-popup {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  min-width: 180px;
  max-width: min(420px, calc(100% - 16px));
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(16 32 40 / 16%);
}

.ac-item {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 15px;
  white-space: nowrap;
  cursor: pointer;
}

.ac-item[aria-selected="true"] {
  background: var(--accent-soft);
}

.ac-item:hover {
  background: var(--bg-soft);
}

.ac-item[aria-selected="true"]:hover {
  background: var(--accent-soft);
}

.ac-typed {
  color: var(--muted);
}

.ac-item strong {
  overflow: hidden;
  margin-right: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
}

.ac-item kbd {
  margin-left: auto;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font);
  font-size: 11.5px;
}

.ac-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.ac-form .field {
  flex: 1;
}

.ac-form .util {
  height: 38px;
}

/* One entry per line, so a comma can stay inside a phrase. */
.ac-input {
  display: block;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: vertical;
}

/* One entry per row; .word-row (later in this file) has four columns. */
.word-row.ac-row {
  grid-template-columns: 1fr auto;
}

/* Spell check --------------------------------------------------------------- */

.spell-popup {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  max-width: min(320px, calc(100% - 16px));
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(16 32 40 / 16%);
}

.spell-option {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.spell-option.is-suggestion {
  font-size: 15px;
  font-weight: 650;
}

.spell-option:hover,
.spell-option:focus-visible {
  background: var(--accent-soft);
}

.spell-option:focus-visible {
  outline-offset: -2px;
}

.spell-option small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.spell-none {
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
}

.spell-none:focus-visible {
  outline-offset: -2px;
}

.spell-divider {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
}

/* Ignored words: saved ones, then the ones kept only for this tab. */
.list-title {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.word-row.ignored-row {
  display: flex;
}

.ignored-word {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--bg-soft);
  font-size: 15px;
  overflow-wrap: anywhere;
}

/* Templates ----------------------------------------------------------------- */

/* The first templates on the list, as buttons under the text box. */
.quick-templates {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.quick-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.quick-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* The name is cut short inside the button, not the button itself, so its
   tooltip isn't cut off too. */
.quick-template span {
  display: block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-text {
  display: block;
  width: 100%;
  min-height: 180px;
  max-height: 45vh;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.55;
  resize: vertical;
}

.template-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

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

.editor-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  min-height: 42px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13.5px;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}

.status {
  margin-left: auto;
  color: var(--accent);
  font-weight: 600;
}

.names-toggle {
  color: var(--muted);
  font-weight: 500;
}

/* Button names switched off, or the button was just pressed. */
.no-tips [data-tip]::after,
[data-tip].tip-pressed::after {
  display: none !important;
}

.noscript {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent-soft);
}

/* My words ---------------------------------------------------------------- */

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.words-dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgb(16 32 40 / 22%);
}

.words-dialog::backdrop {
  background: rgb(16 32 40 / 40%);
}

.dialog-body {
  padding: 20px 22px 18px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.dialog-note,
.dialog-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.dialog-hint {
  font-size: 13px;
}

.icon-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--border);
  background: var(--bg-soft);
  color: var(--text);
}

.word-form {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: end;
  gap: 8px;
  margin-top: 16px;
}

.word-form label span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.word-form input,
.word-input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.word-form .util {
  height: 38px;
}

.word-arrow {
  display: flex;
  align-items: center;
  height: 38px;
  color: var(--accent);
}

.dialog-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 1.6em;
  margin: 10px 0 0;
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 600;
}

.word-list {
  max-height: 40vh;
  overflow-y: auto;
  margin: 6px 0 0;
  padding: 0;
  border-top: 1px solid var(--border);
  list-style: none;
}

.word-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

li.word-row + li.word-row {
  margin-top: 0;
}

.word-input {
  border-color: transparent;
  background: var(--bg-soft);
}

.word-input:hover,
.word-input:focus {
  border-color: var(--border-strong);
  background: var(--surface);
}

.word-empty {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.dialog-warning {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff4e5;
  color: #6b3d00;
  font-size: 13.5px;
}

.dialog-privacy {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  font-size: 13.5px;
  line-height: 1.45;
}

.dialog-privacy .icon {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--accent);
}

/* My tools ---------------------------------------------------------------- */

.dialog-setting {
  display: flex;
  margin: 10px 0 0;
  color: var(--text);
  font-size: 14px;
}

.act-add {
  border-style: dashed;
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
}

.dialog-actions .spacer {
  flex: 1;
}

.util.is-danger {
  border-color: #e3b5af;
  color: #a3261b;
}

.util.is-danger:hover {
  border-color: #a3261b;
}

.tool-list {
  max-height: 40vh;
  overflow-y: auto;
  margin: 6px 0 0;
  padding: 0;
  border-top: 1px solid var(--border);
  list-style: none;
}

.tool-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

li.tool-item + li.tool-item {
  margin-top: 0;
}

.tool-item-text {
  flex: 1;
  min-width: 0;
}

.tool-item-name {
  display: block;
}

.tool-item-steps {
  display: block;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.field {
  display: block;
  margin-top: 16px;
}

.field span,
.steps-field legend {
  display: block;
  margin-bottom: 4px;
  padding: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.field input,
.step-find,
.step-replace,
.step-type {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.steps-field {
  min-width: 0;
  margin: 14px 0 0;
  padding: 0;
  border: 0;
}

.step-list {
  display: grid;
  gap: 8px;
  max-height: 36vh;
  overflow-y: auto;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.step-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}

li.step-row + li.step-row {
  margin-top: 0;
}

.step-type {
  width: auto;
  padding-right: 6px;
}

.step-find,
.step-replace {
  flex: 1 1 100px;
  min-width: 0;
  width: auto;
}

.step-with {
  color: var(--muted);
  font-size: 14px;
}

.step-row.is-remove .step-with,
.step-row.is-remove .step-replace {
  display: none;
}

.step-whole {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13.5px;
  white-space: nowrap;
  cursor: pointer;
}

.step-whole input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.char-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.chip {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Content ----------------------------------------------------------------- */

.content {
  max-width: 1120px;
  padding-block: 28px 56px;
}

.content > section,
.content > .faq {
  max-width: 820px;
  margin-top: 36px;
}

.content > section:first-child {
  max-width: none;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

h3 {
  margin: 24px 0 8px;
  font-size: 1.15rem;
  line-height: 1.3;
}

h4 {
  margin: 0 0 4px;
  font-size: 1rem;
}

p,
ul,
ol,
dl {
  margin: 0 0 14px;
}

li + li {
  margin-top: 6px;
}

code,
pre {
  font-family: var(--mono);
  font-size: 0.92em;
}

code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--code-bg);
}

pre.code {
  overflow-x: auto;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--code-bg);
  white-space: pre-wrap;
  word-break: break-word;
}

.group-title {
  margin-top: 26px;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.ref-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.ref-card h4 {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* The button's icon next to its name, so the icons are easy to learn. */
.ref-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
}

.ref-icon .icon {
  width: 18px;
  height: 18px;
}

.ref-card p {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

.ref-card .demo {
  margin: 0;
}

.demo {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 10px;
  margin: 16px 0 20px;
}

.demo-side {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}

.demo-side.is-after {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.demo-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.demo pre {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.demo-arrow {
  display: flex;
  align-items: center;
  color: var(--accent);
}

.steps {
  padding-left: 1.4em;
}

.steps li {
  padding-left: 4px;
}

.guide-list {
  padding-left: 1.2em;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 0 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

thead th {
  background: var(--bg-soft);
  font-size: 0.85rem;
}

tbody tr:last-child > * {
  border-bottom: 0;
}

tbody th {
  white-space: nowrap;
}

.term-sample {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
}

.term-sample dt {
  font-weight: 650;
}

.term-sample dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.term-list {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.term-list summary {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.term-list p {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.7;
}

.faq h3 {
  margin-top: 20px;
}

/* Prose pages ------------------------------------------------------------- */

.prose {
  max-width: 780px;
  padding-block: 28px 64px;
}

.prose h1 {
  margin: 0 0 8px;
  font-size: clamp(1.7rem, 1.3rem + 1.4vw, 2.3rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.prose h2 {
  margin-top: 34px;
}

.prose .lede {
  margin-bottom: 20px;
  font-size: 1.12rem;
}

.updated {
  color: var(--muted);
  font-size: 0.92rem;
}

.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13.5px;
}

.crumbs li + li {
  margin-top: 0;
}

.crumbs li + li::before {
  content: "/";
  margin: 0 8px;
  opacity: 0.6;
}

.crumbs a {
  color: var(--muted);
}

/* Footer ------------------------------------------------------------------ */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 14.5px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 28px;
  padding-block: 36px 20px;
}

.footer-about p {
  max-width: 40ch;
  margin-top: 10px;
  color: var(--muted);
}

.site-footer h2 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.site-footer ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer li + li {
  margin-top: 6px;
}

.site-footer nav a {
  color: var(--text);
  text-decoration: none;
}

.site-footer nav a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-base {
  padding-block: 16px 28px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.footer-base p {
  margin: 0;
}

/* Small screens ----------------------------------------------------------- */

@media (max-width: 860px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }

  .footer-about {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding-inline: 16px;
  }

  .tool {
    padding-top: 14px;
  }

  /* Keep the intro short so the text box shows on the first screen. */
  .intro h1 {
    font-size: 1.4rem;
  }

  .tool .lede {
    margin-top: 6px;
    font-size: 15px;
    line-height: 1.5;
  }

  .intro {
    margin-top: 18px;
  }

  .private-note {
    margin: 10px 0 0;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 13px;
  }

  /* All the groups in one strip that scrolls sideways, so the text box stays on
     screen. The fade on the right edge shows there is more. */
  .actions {
    flex-wrap: nowrap;
    gap: 18px;
    overflow-x: auto;
    padding: 10px 40px 10px 14px;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(
      to right,
      #000 calc(100% - 32px),
      transparent
    );
    mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
  }

  .actions::-webkit-scrollbar {
    display: none;
  }

  .group,
  .act,
  .keep {
    flex: none;
  }

  .btn-row {
    flex-wrap: nowrap;
  }

  /* Phone order: find box with its arrows and close, then the replace box, then the rest. */
  .find-bar {
    padding: 8px 12px;
  }

  .find-field.is-find {
    order: 1;
    flex: 1 1 0;
    min-width: 0;
  }

  #find-prev,
  #find-next {
    order: 2;
  }

  .find-close {
    order: 3;
    margin-left: 0;
  }

  .find-field.is-replace {
    order: 4;
    flex: 1 1 100%;
  }

  #replace-one,
  #replace-all {
    order: 5;
  }

  .find-bar .keep {
    order: 6;
  }

  .editor-bar {
    padding: 8px 12px;
  }

  .util span {
    display: none;
  }

  .util.is-primary span {
    display: inline;
  }

  .editor {
    height: 52vh;
  }

  .editor-text {
    padding: 14px 16px;
  }

  .status {
    margin-left: 0;
    flex-basis: 100%;
  }

  .dialog-body {
    padding: 16px;
  }

  .word-form {
    grid-template-columns: 1fr;
  }

  .word-form .word-arrow {
    display: none;
  }

  .word-row {
    gap: 6px;
  }

  .demo {
    grid-template-columns: 1fr;
  }

  .demo-arrow {
    justify-content: center;
    transform: rotate(90deg);
  }

  .ref-grid {
    grid-template-columns: 1fr;
  }

  .term-sample {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .term-sample dd {
    margin-bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
