:root {
  --ink: #151a17;
  --muted: #68706b;
  --paper: #fffdf8;
  --canvas: #f0ede5;
  --lime: #d9ff63;
  --lime-deep: #b9ec29;
  --orange: #ff6f3c;
  --shadow: 0 26px 80px rgba(31, 37, 33, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: radial-gradient(circle at 86% 12%, rgba(217, 255, 99, .26), transparent 26rem), var(--canvas);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { color: inherit; }

.site-header {
  width: min(1480px, calc(100% - 64px));
  height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(21, 26, 23, .12);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
  font-size: 20px;
  font-weight: 850;
  letter-spacing: -.7px;
}
.brand-dot { color: var(--orange); }
.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 8px);
  gap: 2px;
  padding: 5px;
  background: var(--ink);
  border-radius: 4px;
  transform: rotate(-3deg);
}
.brand-mark i { width: 8px; height: 8px; background: var(--lime); }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(3) { background: var(--paper); }
.header-note { font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }

main { width: min(1480px, calc(100% - 64px)); margin: 0 auto; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 80px;
  align-items: end;
  padding: 72px 0 58px;
}
.eyebrow {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: -45px;
  color: #485049;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.eyebrow span { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }
.hero h1 {
  margin: 0;
  font-size: clamp(54px, 6.2vw, 104px);
  line-height: .89;
  letter-spacing: -.065em;
  font-weight: 850;
}
.hero h1 em {
  position: relative;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  letter-spacing: -.055em;
}
.hero h1 em::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: -1%;
  right: -4%;
  bottom: 3%;
  height: 27%;
  background: var(--lime);
  transform: rotate(-1.5deg);
}
.hero > p { max-width: 360px; margin: 0 0 5px; color: var(--muted); font-size: 18px; line-height: 1.58; }

.studio {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  min-height: 790px;
  border: 1px solid rgba(21, 26, 23, .16);
  border-radius: 22px;
  overflow: hidden;
  background: rgba(255, 253, 248, .64);
  box-shadow: var(--shadow);
  margin: 20px 0 28px;
}
.editor-panel { padding: 34px; border-right: 1px solid rgba(21, 26, 23, .14); background: var(--paper); }
.panel-heading { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 32px; }
.panel-heading.compact { margin: 0; }
.step {
  display: grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--lime);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .06em;
}
.panel-heading h2 { margin: 0 0 5px; font-size: 18px; letter-spacing: -.025em; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.field-label {
  display: block;
  margin: 23px 0 9px;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.words-label-row { display: flex; align-items: end; justify-content: space-between; }
.words-label-row span { margin-bottom: 9px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.title-input, textarea {
  width: 100%;
  border: 1px solid #cbc9c2;
  border-radius: 11px;
  background: #faf8f2;
  color: var(--ink);
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.title-input { height: 48px; padding: 0 14px; font-weight: 700; }
textarea {
  height: 266px;
  padding: 15px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.75;
}
.title-input:focus, textarea:focus { border-color: var(--ink); background: #fff; box-shadow: 0 0 0 3px rgba(217, 255, 99, .62); }
.suggestions-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #cfcdc5;
  border-radius: 12px;
  background: #f4f1e8;
}
.suggestions-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}
.suggestions-heading > div { display: flex; align-items: center; gap: 7px; }
.suggestions-heading strong { font-size: 11px; letter-spacing: .02em; }
.suggestions-heading > span { color: var(--muted); font-size: 9px; text-align: right; }
.spark { display: grid; place-items: center; width: 21px; height: 21px; border-radius: 6px; background: var(--lime); font-size: 12px; }
.suggestion-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 29px; }
.suggestion-chip {
  position: relative;
  max-width: 100%;
  border: 1px solid #c9c6bd;
  border-radius: 999px;
  padding: 6px 25px 6px 10px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color .16s, background .16s, transform .16s;
}
.suggestion-chip::after {
  content: "+";
  position: absolute;
  right: 9px;
  color: var(--orange);
  font-size: 14px;
  line-height: 10px;
}
.suggestion-chip:hover { border-color: var(--ink); background: var(--lime); transform: translateY(-1px); }
.suggestion-chip.is-added { border-color: #c8db8d; background: #eef7d1; color: #77806e; cursor: default; }
.suggestion-chip.is-added::after { content: "✓"; color: #4b6c00; font-size: 10px; }
.suggestion-placeholder {
  width: 74px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e1ded5 25%, #ece9e0 50%, #e1ded5 75%);
  background-size: 200% 100%;
  animation: suggestion-loading 1.2s infinite linear;
}
.suggestion-placeholder:nth-child(2) { width: 101px; }
.suggestion-placeholder:nth-child(3) { width: 84px; }
@keyframes suggestion-loading { to { background-position: -200% 0; } }
.suggestion-empty { color: var(--muted); font-size: 10px; line-height: 1.45; }
.suggestion-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 11px;
}
.suggestion-actions button {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  font-size: 9px;
  font-weight: 850;
  text-decoration: underline;
  text-decoration-color: #becb91;
  text-underline-offset: 3px;
}
.suggestion-actions button:disabled { color: #a2a49f; cursor: default; text-decoration: none; }
.format-hint { margin: 8px 1px 0; color: var(--muted); font-size: 11px; }
.format-hint b { color: var(--ink); }
.sample-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 21px;
  color: var(--muted);
  font-size: 11px;
}
.sample-button {
  border: 1px solid #d5d2ca;
  border-radius: 999px;
  padding: 6px 10px;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
  transition: .18s ease;
}
.sample-button:hover { border-color: var(--ink); background: var(--ink); color: #fff; transform: translateY(-1px); }
.unplaced-box {
  margin-top: 18px;
  padding: 11px 12px;
  border-left: 3px solid var(--orange);
  background: #fff1eb;
  color: #79402d;
  font-size: 11px;
  line-height: 1.5;
}
.generate-button {
  width: 100%;
  height: 57px;
  margin-top: 23px;
  padding: 0 8px 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: 11px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  transition: transform .18s, box-shadow .18s;
}
.generate-button:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(21, 26, 23, .18); }
.button-arrow {
  display: grid;
  place-items: center;
  width: 41px;
  height: 41px;
  border-radius: 8px;
  background: var(--lime);
  color: var(--ink);
  font-size: 21px;
}
.privacy-note { margin: 13px 12px 0; color: #858b87; text-align: center; font-size: 10px; line-height: 1.45; }

.preview-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 34px;
  background: linear-gradient(rgba(21, 26, 23, .025) 1px, transparent 1px), linear-gradient(90deg, rgba(21, 26, 23, .025) 1px, transparent 1px), #e7e4dc;
  background-size: 22px 22px;
}
.preview-topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px 24px;
  margin-bottom: 18px;
}
.preview-heading-line { display: flex; align-items: center; gap: 12px; }
.preview-tools { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.preview-switches { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.export-actions { display: flex; gap: 8px; }
.view-switch, .orientation-switch {
  display: flex;
  padding: 3px;
  border: 1px solid #cbc7bd;
  border-radius: 9px;
  background: rgba(255, 255, 255, .5);
}
.view-switch button, .orientation-switch button {
  border: 0;
  border-radius: 6px;
  padding: 8px 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}
.orientation-switch button { display: inline-flex; align-items: center; gap: 5px; }
.orientation-switch button span { font-size: 16px; line-height: .7; }
.view-switch button.is-active, .orientation-switch button.is-active { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(21, 26, 23, .1); }
.rebuild-button {
  min-height: 38px;
  border: 1px solid #a7ca3c;
  border-radius: 9px;
  padding: 0 13px;
  background: var(--lime);
  cursor: pointer;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
  transition: transform .16s, background .16s;
}
.rebuild-button:hover { background: var(--lime-deep); transform: translateY(-1px); }
.paper {
  flex: 1;
  width: 100%;
  min-height: 590px;
  padding: 34px clamp(24px, 4vw, 56px) 21px;
  background: #fff;
  box-shadow: 0 13px 40px rgba(21, 26, 23, .13);
  transform: rotate(.15deg);
  transition: aspect-ratio .25s ease, min-height .25s ease;
}
.paper.is-portrait { aspect-ratio: 210 / 297; }
.paper.is-landscape {
  aspect-ratio: 297 / 210;
  min-height: 510px;
}
.paper.is-landscape .grid-scroll { padding-block: 22px; }
.paper.is-landscape .crossword-grid { --cell-size: 25px; }
.paper.is-landscape .clues { gap: 28px; padding-top: 17px; }
.paper.is-landscape .clues li { margin-bottom: 5px; font-size: 8px; line-height: 1.35; }
.paper.is-landscape .clues h4 { margin-bottom: 9px; font-size: 8px; }
.paper.is-landscape .paper-signature { margin-top: 14px; }
.paper-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding-bottom: 22px;
  border-bottom: 2px solid var(--ink);
}
.paper-heading > div > span { color: #000; font-size: 9px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.paper h3 { margin: 5px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(23px, 2.3vw, 34px); font-weight: 400; letter-spacing: -.035em; }
.paper-meta {
  display: grid;
  grid-template-columns: auto 160px;
  gap: 6px 8px;
  color: #7b817d;
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.paper-meta i { border-bottom: 1px solid #a7aaa7; }
.grid-scroll { width: 100%; overflow: auto; padding: 31px 4px 27px; scrollbar-width: thin; }
.crossword-grid {
  --cell-size: 38px;
  display: grid;
  justify-content: center;
  grid-template-columns: repeat(var(--cols, 1), var(--cell-size));
  grid-template-rows: repeat(var(--rows, 1), var(--cell-size));
  min-width: max-content;
}
.grid-cell {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--cell-size);
  height: var(--cell-size);
  margin: -1px 0 0 -1px;
  border: 1.35px solid #202521;
  background: #fff;
  cursor: pointer;
  font-size: calc(var(--cell-size) * .47);
  font-weight: 850;
  line-height: 1;
  transition: background .13s, color .13s;
}
.grid-cell:hover, .grid-cell.is-highlighted { background: var(--lime); }
.grid-cell.is-crossing { background-image: linear-gradient(135deg, transparent 83%, rgba(255, 111, 60, .5) 84%); }
.grid-cell.is-highlighted.is-crossing { background-color: var(--lime); }
.grid-cell .cell-number {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: max(6px, calc(var(--cell-size) * .19));
  font-weight: 800;
}
.crossword-grid.is-puzzle .cell-letter { visibility: hidden; }
.grid-void { width: var(--cell-size); height: var(--cell-size); }
.empty-grid {
  display: grid;
  place-items: center;
  width: min(460px, 90%);
  min-height: 230px;
  margin: 0 auto;
  border: 1px dashed #bbb8af;
  color: #858b87;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
}
.clues {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 34px;
  padding-top: 21px;
  border-top: 1px solid #d6d3cb;
}
.clues h4 { display: flex; align-items: center; gap: 7px; margin: 0 0 13px; font-size: 10px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.clues h4 span { color: #000; font-size: 15px; }
.clues ol { list-style: none; margin: 0; padding: 0; }
.clues li {
  position: relative;
  margin: 0 0 8px;
  padding-left: 26px;
  color: #4f5651;
  font-size: 10px;
  line-height: 1.45;
  cursor: default;
}
.clues li b { position: absolute; left: 0; color: var(--ink); font-size: 9px; }
.clues li.is-highlighted { color: var(--ink); text-decoration: underline; text-decoration-color: var(--lime-deep); text-decoration-thickness: 3px; }
.paper-signature { margin-top: 24px; color: #a3a6a2; text-align: right; font-size: 7px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.secondary-button, .download-button {
  min-height: 42px;
  border-radius: 9px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  transition: transform .16s, background .16s;
}
.secondary-button { border: 1px solid #aaa79e; background: rgba(255, 255, 255, .4); }
.download-button { border: 1px solid var(--ink); background: var(--ink); color: #fff; }
.secondary-button:hover, .download-button:hover { transform: translateY(-1px); }
.secondary-button:hover { background: #fff; }
.download-button:hover { background: #2d352f; }

.service-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 0 34px;
  color: var(--muted);
  font-size: 10px;
}
.service-footer a { color: inherit; text-underline-offset: 3px; }
.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 25px;
  padding: 12px 17px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
  font-size: 12px;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 15px);
  transition: .25s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1080px) {
  .studio { grid-template-columns: 360px minmax(0, 1fr); }
  .editor-panel, .preview-panel { padding: 28px; }
  .preview-topbar { grid-template-columns: 1fr; }
  .preview-tools { justify-content: flex-start; }
  .paper { padding-inline: 24px; }
  .crossword-grid { --cell-size: 32px; }
}
@media (max-width: 860px) {
  .site-header, main { width: min(100% - 34px, 700px); }
  .site-header { height: 72px; }
  .studio { display: block; }
  .editor-panel { border-right: 0; border-bottom: 1px solid rgba(21, 26, 23, .14); }
  .paper { min-height: 520px; }
  .paper.is-landscape { min-height: 470px; }
}
@media (max-width: 560px) {
  .site-header, main { width: calc(100% - 24px); }
  .studio { border-radius: 16px; }
  .editor-panel, .preview-panel { padding: 21px 16px; }
  .preview-heading-line { align-items: flex-start; justify-content: space-between; }
  .preview-tools { align-items: stretch; flex-direction: column; }
  .preview-switches { justify-content: flex-start; width: 100%; }
  .view-switch { flex: 1; }
  .view-switch button { flex: 1; }
  .orientation-switch { width: 100%; }
  .orientation-switch button { flex: 1; justify-content: center; padding-inline: 7px; }
  .export-actions { width: 100%; }
  .export-actions .secondary-button, .export-actions .download-button { flex: 1; }
  .paper { padding: 25px 15px 18px; }
  .paper-heading { display: block; }
  .paper-meta { display: none; }
  .paper.is-landscape { min-height: 390px; }
  .paper.is-landscape .grid-scroll { padding-block: 15px; }
  .paper.is-landscape .crossword-grid { --cell-size: 20px; }
  .paper.is-landscape .clues { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding-top: 12px; }
  .paper.is-landscape .clues li { margin-bottom: 4px; padding-left: 15px; font-size: 6px; }
  .paper.is-landscape .clues li b { font-size: 6px; }
  .paper.is-landscape .clues h4 { gap: 3px; margin-bottom: 7px; font-size: 6px; }
  .paper.is-landscape .clues h4 span { font-size: 9px; }
  .crossword-grid { --cell-size: 29px; justify-content: start; }
  .clues { grid-template-columns: 1fr; gap: 18px; }
  .secondary-button, .download-button { width: 100%; }
  .service-footer { align-items: flex-start; flex-direction: column; }
}
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .site-header, .editor-panel, .preview-topbar, .service-footer, .toast { display: none !important; }
  main, .studio, .preview-panel, .paper {
    display: block;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: #fff;
    box-shadow: none;
    transform: none;
  }
  .paper { padding: 12mm !important; }
  .paper.is-portrait { aspect-ratio: 210 / 297; }
  .paper.is-landscape {
    display: block;
    aspect-ratio: 297 / 210;
  }
  .paper-meta {
    display: grid !important;
    grid-template-columns: auto 45mm;
    gap: 3mm 3mm;
    font-size: 10pt;
  }
  .paper-meta i { border-bottom: .35mm solid #000; }
  .clues { gap: 12mm; padding-top: 5mm; }
  .clues h4 {
    margin-bottom: 4mm;
    font-size: var(--print-clue-heading-size, 11pt);
    letter-spacing: .06em;
  }
  .clues h4 span { font-size: var(--print-clue-arrow-size, 16pt); }
  .clues li {
    margin-bottom: 2.5mm;
    padding-left: 9mm;
    color: #000;
    font-size: var(--print-clue-size, 11pt);
    line-height: 1.35;
  }
  .clues li b { font-size: var(--print-clue-number-size, 10pt); }
  .paper-heading > div > span, .clues h4 span { color: #000 !important; }
  .grid-cell, .grid-cell:hover, .grid-cell.is-highlighted, .grid-cell.is-highlighted.is-crossing {
    color: #000 !important;
    background-color: #fff !important;
    background-image: none !important;
  }
  .crossword-grid { --cell-size: 8mm; }
  .paper-signature { margin-top: 12mm; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
