:root {
  --ink: #1d1f23;
  --muted: #5d6470;
  --line: #d9dde3;
  --bg: #f7f5f0;
  --card: #fff;
  --accent: #1f6f5c;
  --accent-2: #e8f3ef;
  --warn: #9a3b00;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 18px; }

/* header */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.brand { font-weight: 800; font-size: 1.2rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a { text-decoration: none; color: var(--ink); padding: 6px 10px; border-radius: 8px; font-size: 0.95rem; }
.site-nav a:hover, .site-nav a[aria-current="page"] { background: var(--accent-2); color: var(--accent); }

main { padding: 22px 0 40px; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); line-height: 1.2; margin: 6px 0 8px; letter-spacing: -0.015em; }
h2 { font-size: 1.3rem; margin: 28px 0 8px; }
h3 { font-size: 1.05rem; margin: 0 0 6px; }
.lead { color: var(--muted); margin: 0 0 18px; max-width: 70ch; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* tool layout */
.tool { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 18px; align-items: start; }
@media (max-width: 800px) { .tool { grid-template-columns: 1fr; } }
form label { display: block; font-weight: 600; font-size: 0.93rem; margin: 10px 0 4px; }
form label:first-child { margin-top: 0; }
input[type=text], textarea, select {
  width: 100%; font: inherit; font-size: 16px; padding: 8px 10px; border: 1px solid #b9c0c8; border-radius: 8px; background: #fff; color: var(--ink);
}
textarea { min-height: 220px; resize: vertical; line-height: 1.4; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 4px 0 0; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
button, .btn {
  font: inherit; font-size: 0.97rem; border: 1px solid var(--accent); background: #fff; color: var(--accent);
  padding: 9px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block;
}
button.primary, .btn.primary { background: var(--accent); color: #fff; }
button:hover, .btn:hover { filter: brightness(0.95); }
.msg { color: var(--warn); font-size: 0.92rem; margin: 10px 0 0; }
.msg:empty { display: none; }

/* preview */
.preview h2.puzzle-title { margin: 0 0 4px; text-align: center; font-size: 1.4rem; }
.preview .instructions { text-align: center; color: var(--muted); font-size: 0.92rem; margin: 0 0 12px; }
.ws-svg, .cw-svg { display: block; width: 100%; max-width: 620px; height: auto; margin: 0 auto; font-family: "Helvetica Neue", Arial, sans-serif; }
.ws-svg text { fill: #111; }
.cw-svg { max-width: 560px; }
.cw-svg .cw-num { fill: #333; }
.cw-svg text { fill: #111; font-weight: 700; }
.cw-svg text.cw-num { font-weight: 400; }
.word-list { list-style: none; padding: 0; margin: 16px auto 0; max-width: 620px; columns: 4 130px; column-gap: 18px; }
.word-list li { padding: 2px 0 2px 22px; position: relative; break-inside: avoid; }
.word-list li::before { content: ""; position: absolute; left: 0; top: 7px; width: 12px; height: 12px; border: 1.5px solid #555; border-radius: 2px; }
.large .word-list { font-size: 1.3rem; columns: 3 150px; }
.clue-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 18px; }
@media (max-width: 600px) { .clue-cols { grid-template-columns: 1fr; } }
.clues { padding: 0; margin: 0; list-style: none; }
.clues li { margin: 0 0 6px; padding-left: 2em; text-indent: -2em; }
.clues .len { color: var(--muted); white-space: nowrap; }
.large .clues { font-size: 1.25rem; }
.solution-toggle { margin: 14px auto 0; text-align: center; }
details.solution { margin-top: 18px; }
details.solution summary { cursor: pointer; font-weight: 600; color: var(--accent); }
details.solution .ws-svg, details.solution .cw-svg { margin-top: 12px; max-width: 480px; }

.content { max-width: 72ch; }
.content p, .content li { color: #2c3037; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; padding: 0; list-style: none; }
.theme-grid a { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: var(--ink); height: 100%; }
.theme-grid a:hover { border-color: var(--accent); }
.theme-grid small { display: block; color: var(--muted); }
.tag { display: inline-block; font-size: 0.75rem; background: var(--accent-2); color: var(--accent); border-radius: 99px; padding: 1px 8px; margin-bottom: 4px; }
.crumbs { font-size: 0.88rem; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }

/* footer */
.site-footer { border-top: 1px solid var(--line); background: var(--card); padding: 18px 0 26px; font-size: 0.9rem; color: var(--muted); }
.site-footer nav { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.site-footer a { color: var(--muted); }
.site-footer .made { font-size: 0.8rem; }

.print-only { display: none; }

/* print: puzzle on page 1, answers on page 2, no site chrome */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 12pt; }
  .site-header, .site-footer, .no-print, form, .buttons, .lead, .crumbs, .content, details.solution, .ad-slot { display: none !important; }
  main { padding: 0; }
  .wrap { max-width: none; padding: 0; }
  .tool { display: block; }
  .card { border: 0; padding: 0; }
  .ws-svg, .cw-svg { max-width: 17cm; }
  .print-only { display: block; break-before: page; page-break-before: always; }
  .print-only .ws-svg, .print-only .cw-svg { max-width: 15cm; }
  h1.page-h1 { display: none; }
  .clues li { break-inside: avoid; }
}
.brand-mark { width: 26px; height: 26px; vertical-align: middle; margin: -3px 8px 0 0; }
