:root {
  color-scheme: light;
  --bg: #fff3df;
  --panel: rgba(255, 255, 255, 0.72);
  --ink: #352016;
  --muted: #755946;
  --line: rgba(111, 74, 54, 0.18);
  --primary: #128578;
  --primary-dark: #0b625a;
  --accent: #dd7a13;
  --soft: #fbe1b8;
  --cell: #fffaf1;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

a {
  color: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  text-decoration: none;
}

.brand img {
  width: 42px;
  height: 42px;
}

.topbar-actions,
.example-grid,
.share-channel-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 22px;
  width: min(1220px, calc(100% - 32px));
  margin: 18px auto 60px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(111, 74, 54, 0.09);
}

.editor-panel {
  padding: 22px;
}

.result-panel {
  min-height: 620px;
  padding: 22px;
}

.section-header {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #b64b2e;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 2rem;
  line-height: 1.08;
}

h2 {
  font-size: 1.5rem;
}

.section-header p,
.hint,
.status {
  color: var(--muted);
  line-height: 1.55;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: #6b351f;
  font-weight: 800;
}

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

textarea {
  resize: vertical;
}

.primary-button,
.secondary-button,
.example-grid button,
.share-channel {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  background: var(--primary);
  color: #fff;
}

.secondary-button,
.example-grid button,
.share-channel {
  border: 1px solid var(--line);
  background: #fffaf1;
  color: var(--ink);
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.example-grid {
  margin: 18px 0;
}

.status {
  min-height: 24px;
  margin: 12px 0 0;
  font-size: 0.94rem;
}

.status.is-error {
  color: #a33a25;
}

.preview-stack {
  display: grid;
  gap: 22px;
}

.worksheet-page {
  position: relative;
  width: min(100%, 780px);
  min-height: 920px;
  margin: 0 auto;
  padding: 34px;
  border: 1px solid rgba(111, 74, 54, 0.22);
  border-radius: 8px;
  background: #fffaf1;
}

.worksheet-print-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.worksheet-print-header p,
.worksheet-note {
  color: #b64b2e;
  font-weight: 900;
}

.worksheet-print-header h2 {
  margin: 4px 0 0;
  font-size: 2rem;
}

.worksheet-print-header span {
  white-space: nowrap;
  color: var(--muted);
  font-weight: 800;
}

.worksheet-note {
  margin-bottom: 24px;
  color: var(--ink);
}

.matching-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 42px;
}

.matching-grid ol {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.matching-grid li,
.worksheet-solution-list li,
.circle-words p,
.counting-row {
  border: 2px solid #d79c6b;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 900;
}

.matching-grid li {
  padding: 15px 18px;
}

.worksheet-solution-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 22px;
}

.worksheet-solution-list li {
  padding: 13px 16px;
}

.worksheet-task {
  font-size: 1.25rem;
}

.circle-words {
  display: grid;
  gap: 14px;
}

.circle-words p {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 14px;
}

.circle-words span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid #ead4b7;
  border-radius: 999px;
  background: #fffaf1;
}

.circle-words .marked-letter {
  border-color: var(--primary);
  background: #dff5ef;
}

.counting-list {
  display: grid;
  gap: 16px;
}

.counting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 18px;
  align-items: center;
  padding: 14px;
}

.counting-shapes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.counting-shapes svg {
  width: 34px;
  height: 34px;
  fill: #f6b15f;
  stroke: #6f4a36;
  stroke-width: 1.5;
}

.counting-row label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 1rem;
}

.counting-row label span {
  display: inline-block;
  width: 58px;
  border-bottom: 3px solid var(--ink);
}

.worksheet-branding {
  position: absolute;
  right: 34px;
  bottom: 26px;
  left: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid #ead4b7;
  padding-top: 14px;
  color: var(--muted);
  font-size: 0.82rem;
}

.worksheet-branding div:first-child {
  display: grid;
  gap: 2px;
}

.worksheet-branding a {
  color: var(--primary-dark);
}

.worksheet-qr {
  width: 54px;
  height: 54px;
  border: 2px solid var(--ink);
  background: #fff;
  object-fit: contain;
}

.share-modal {
  position: fixed;
  z-index: 20;
  inset: 0;
}

.share-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(53, 32, 22, 0.56);
}

.share-modal-panel {
  position: relative;
  width: min(560px, calc(100% - 28px));
  margin: 8vh auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf1;
  padding: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
}

.share-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.share-modal-close {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 1.6rem;
  cursor: pointer;
}

.share-link-field {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  font-weight: 800;
}

.share-link-field span {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.print-sheets {
  display: none;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .topbar,
  .app-shell {
    width: min(100% - 24px, 1220px);
  }

  .topbar-actions,
  .topbar-actions .secondary-button,
  .example-grid button {
    width: 100%;
  }

  .worksheet-page {
    min-height: 820px;
    padding: 20px;
  }

  .worksheet-print-header,
  .worksheet-branding {
    flex-direction: column;
  }

  .worksheet-print-header span {
    white-space: normal;
  }

  .matching-grid,
  .counting-row,
  .share-link-field span {
    grid-template-columns: 1fr;
  }

  .worksheet-branding {
    position: static;
    margin-top: 32px;
  }
}

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

  .topbar,
  .app-shell,
  .share-modal {
    display: none !important;
  }

  .print-sheets {
    display: block;
  }

  .worksheet-page {
    width: 190mm;
    min-height: 270mm;
    margin: 0 auto;
    break-after: page;
    page-break-after: always;
    border: 0;
    box-shadow: none;
  }

  .worksheet-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}
