:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #171a1f;
  --muted: #5b6472;
  --line: #d8dce3;
  --accent: #1d5f4f;
  --accent-ink: #ffffff;
  --warn: #8a4b00;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --panel: #1c2026;
    --ink: #eef1f5;
    --muted: #a3adbb;
    --line: #333a44;
    --accent: #5fd0ae;
    --accent-ink: #10231d;
    --warn: #f0b36a;
  }
}

* { box-sizing: border-box; }

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

.wrap { max-width: 46rem; margin: 0 auto; padding: 0 1rem; }

.head { padding: 2rem 0 0.5rem; }

.kicker {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

h1 { font-size: clamp(1.4rem, 4.5vw, 2rem); line-height: 1.2; margin: 0 0 0.6rem; }
h2 { font-size: 1.05rem; margin: 0; }

.lead { margin: 0 0 0.6rem; color: var(--muted); max-width: 40rem; }
.lead.small { font-size: 0.85rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.sub { margin: 0.35rem 0 0.6rem; font-size: 0.85rem; color: var(--muted); }
.sub.strong { color: var(--ink); font-weight: 600; margin-bottom: 0.2rem; }
.sub strong { color: var(--ink); }
.gap-top { margin-top: 0.5rem; }

.grid2 { display: grid; gap: 0.75rem; grid-template-columns: 1fr; }
@media (min-width: 34rem) { .grid2 { grid-template-columns: 1fr 1fr; } }

.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.75rem; }

label { font-size: 0.9rem; font-weight: 600; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.8rem; }

input, textarea, select, button {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}

textarea { resize: vertical; width: 100%; }

input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

button {
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  font-weight: 500;
}

button.tiny { font-size: 0.82rem; padding: 0.3rem 0.6rem; }
button:disabled { opacity: 0.45; cursor: default; }

.copy { font-size: 0.85rem; padding: 0.35rem 0.7rem; }

/* the opener choice and its hint */
.opener-row select { padding: 0.35rem 0.5rem; font-size: 0.9rem; }
.opener-row .opener-help { flex: 1 1 12rem; min-width: 0; }

/* the pick / reorder list */
.items-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem;
  margin: 0 0 0.9rem;
  background: var(--bg);
}

/* what each of the four buttons under the list does: one short line each */
.btn-key {
  margin: 0.15rem 0 0.5rem;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}
.btn-key li { margin: 0.2rem 0; }
.btn-key strong { color: var(--ink); }

.items { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.4rem 0 0.6rem; }

.item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
}

.item .pick { flex: 0 0 auto; width: 1.15rem; height: 1.15rem; margin: 0; }
.item .item-text { flex: 1 1 auto; font-size: 0.9rem; overflow-wrap: anywhere; }

/* the new / edited tag on a row, shown until the list is marked again */
.item-tag {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
}

.item-tag.is-new { color: var(--accent); border-color: var(--accent); }
.item-tag.is-edited { color: var(--warn); border-color: var(--warn); }
.item-tag:empty { display: none; padding: 0; border: 0; }

/* under a row tagged "edited": the old line it reads like */
.item-was {
  flex: 1 1 100%;
  margin: 0 0 0 1.65rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.item-was[hidden] { display: none; }

/* When the old line is too long to sit whole under the row it is cut short, and the cut hint
   is a button: one press shows the whole old line, another cuts it back. A touch screen can
   reach that; the old title attribute it used to carry could not be reached without a pointer.
   Everything else on the row keeps its own styling, so this only overrides the plain button. */
button.item-was {
  text-align: left;
  padding: 0.1rem 0.35rem;
  font-weight: 400;
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 6px;
}

button.item-was[aria-expanded="true"] {
  border-style: solid;
  border-color: var(--accent);
  color: var(--ink);
}

button.move {
  flex: 0 0 auto;
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  padding: 0.15rem 0.45rem;
  font-size: 0.9rem;
  line-height: 1.2;
}

.out {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  background: var(--bg);
  min-height: 4.5rem;
}

.count { margin: 0.4rem 0 0; font-size: 0.82rem; color: var(--muted); }
.count.over { color: var(--warn); font-weight: 700; }

/* the rendered preview of the entry, under the snippet in step 3 */
.preview-h { font-size: 0.95rem; margin: 1rem 0 0; }
.preview {
  margin-top: 0.5rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.9rem 0.8rem;
  background: var(--bg);
}
.preview-title { font-size: 0.95rem; margin: 0 0 0.4rem; }
.preview ul { margin: 0.2rem 0 0; padding-left: 1.2rem; font-size: 0.9rem; }
.preview li { margin: 0.2rem 0; overflow-wrap: anywhere; }
.preview-problems { margin: 0.55rem 0 0; font-size: 0.85rem; color: var(--muted); }
.preview-empty { margin: 0; font-size: 0.85rem; color: var(--muted); }

.lint { margin: 0.2rem 0 0; padding-left: 1.1rem; font-size: 0.9rem; }
.lint li { margin: 0.25rem 0; }
.lint .ok { color: var(--muted); }

.status {
  min-height: 1.4rem;
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0.5rem 0 2rem;
}

.foot {
  border-top: 1px solid var(--line);
  padding: 1.2rem 0 2.5rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.foot p { margin: 0 0 0.5rem; }
a { color: var(--accent); }

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