@font-face {
  font-family: "Dancing Script";
  src: url("/assets/DancingScript-Latin-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

.tool select,
.tool input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

.worksheet-layout {
  display: grid;
  grid-template-columns: minmax(250px, 0.8fr) minmax(0, 1.2fr);
  align-items: start;
  gap: 22px;
  margin-top: 26px;
}

.worksheet-controls {
  display: grid;
  gap: 16px;
}

.starter-picker {
  display: grid;
  min-width: 0;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.starter-picker legend {
  margin-bottom: 8px;
  padding: 0;
  font-weight: 700;
}

.starter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.starter-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font: inherit;
}

.starter-actions button:hover {
  border-color: var(--blue);
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.control-grid label {
  font-size: 0.9rem;
}

.worksheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 9px 15px;
  color: #fff;
  background: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}

.primary-action:hover {
  background: var(--blue);
}

.secondary-action {
  color: var(--ink);
  background: transparent;
}

.secondary-action:hover {
  background: #eae4d9;
}

.worksheet-preview {
  --worksheet-size: 36px;
  min-width: 0;
  aspect-ratio: 8.5 / 11;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: #fff;
  box-shadow: 0 12px 35px #2720190d;
}

.worksheet-preview[data-paper="a4"] {
  aspect-ratio: 210 / 297;
}

.practice-row {
  position: relative;
  display: flex;
  min-height: 70px;
  align-items: end;
  border-bottom: 1px solid #b9c3d1;
  padding: 8px 24px 12px;
  background-image: linear-gradient(
    to bottom,
    transparent 61%,
    #d7dee9 62%,
    #d7dee9 63%,
    transparent 64%
  );
  font-family: "Dancing Script", cursive;
  font-size: var(--worksheet-size);
  line-height: 1.15;
}

.practice-row span {
  max-width: 100%;
  opacity: var(--ink-opacity);
}

.practice-row.trace span {
  color: #52739c;
}

.practice-row small {
  position: absolute;
  right: 2px;
  bottom: 4px;
  color: #96a0ad;
  font: 600 0.68rem/1 system-ui, sans-serif;
}

@media (max-width: 700px) {
  .worksheet-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .worksheet-preview {
    padding: 18px;
  }
}

@page letter-sheet {
  size: Letter portrait;
  margin: 12mm;
}

@page a4-sheet {
  size: A4 portrait;
  margin: 12mm;
}

@media print {
  body {
    background: #fff;
  }

  header,
  footer,
  .worksheet-controls,
  .worksheet-hero > p,
  .worksheet-hero > h1,
  .content {
    display: none !important;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .hero,
  .worksheet-layout {
    display: block;
    margin: 0;
    padding: 0;
  }

  .worksheet-preview {
    width: 100%;
    min-height: 0;
    aspect-ratio: auto;
    overflow: visible;
    border: 0;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
  }

  .worksheet-preview[data-paper="letter"] {
    page: letter-sheet;
  }

  .worksheet-preview[data-paper="a4"] {
    page: a4-sheet;
  }

  .practice-row {
    min-height: 25mm;
    break-inside: avoid;
    padding: 3mm 5mm 4mm;
  }

  .practice-row small {
    display: none;
  }
}
