:root {
  --ink: #111827;
  --muted: #64748b;
  --panel: #eef3f8;
  --paper: #ffffff;
  --line: #d5e2f0;
  --accent: #235f9f;
  --accent-dark: #174876;
  --brand-orange: #f49a21;
  --brand-green: #24856b;
  --soft: #eef6ff;
  --shadow: 0 22px 70px rgba(19, 35, 56, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(244, 154, 33, 0.14), transparent 28rem),
    radial-gradient(circle at top right, rgba(36, 133, 107, 0.1), transparent 30rem),
    linear-gradient(180deg, #fbfdff 0%, #eef3f8 100%),
    var(--panel);
  color: var(--ink);
  font-family: "Montserrat", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 22px;
  max-width: 1380px;
  margin: 0 auto;
}

.control-panel {
  align-self: start;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
  position: sticky;
  top: 24px;
}

.library-link {
  width: max-content;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0 12px;
  border: 1px solid #d8e4f1;
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(18, 32, 45, 0.06);
}

.library-link::before {
  content: "";
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.brand-block {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  padding: 12px;
  border: 1px solid #e2eaf3;
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(244, 154, 33, 0.08), transparent 42%),
    linear-gradient(135deg, #ffffff 0%, #fbfdff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  margin-bottom: 22px;
}

.brand-block > div {
  min-width: 0;
}

.brand-block > div::before {
  content: "SCOLATIO.COM";
  display: block;
  margin-bottom: 3px;
  color: var(--brand-green);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(23, 33, 43, 0.08);
  box-shadow: 0 10px 22px rgba(18, 32, 45, 0.12);
  object-fit: contain;
  padding: 6px;
}

h1 {
  font-size: 1.18rem;
  line-height: 1.08;
  font-weight: 900;
}

.brand-block p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
  margin-top: 5px;
}

.controls {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-weight: 700;
  font-size: 0.86rem;
}

select,
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--ink);
  min-height: 42px;
  padding: 0 12px;
  font-weight: 700;
}

.toggle-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.button-stack {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button:hover {
  border-color: #9db2ca;
  background: #f8fbff;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.primary-btn:hover,
.primary-btn:focus-visible,
.primary-btn:active {
  background: var(--accent-dark);
  color: #fff;
  border-color: var(--accent-dark);
}

.primary-btn:active {
  transform: translateY(1px);
}

.activity-panel {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.worksheet {
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 8px solid var(--brand-orange);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(19, 35, 56, 0.13);
  overflow: hidden;
}

.worksheet-masthead {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  min-height: 120px;
  padding: 24px 34px 22px;
  border-bottom: 1px solid #c7d6e6;
  background:
    linear-gradient(90deg, rgba(244, 154, 33, 0.08), transparent 36%),
    linear-gradient(135deg, #fffdf7 0%, #fbfdff 62%, #f4f8fb 100%);
}

.masthead-brand {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  min-width: 0;
}

.worksheet-logo {
  width: 68px;
  height: 68px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(23, 33, 43, 0.08);
  box-shadow: 0 10px 22px rgba(18, 32, 45, 0.12);
  padding: 7px;
}

.worksheet-kicker {
  color: var(--brand-green);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

#worksheet-title {
  font-size: clamp(1.85rem, 2.8vw, 2.65rem);
  line-height: 1;
  color: #111827;
}

.issue-card {
  min-width: 210px;
  display: grid;
  gap: 6px;
  padding: 12px 0 12px 16px;
  border-left: 4px solid var(--accent);
  color: #243449;
  text-align: right;
  font-weight: 800;
}

.issue-card p {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.15;
}

.issue-card p:empty {
  display: none;
}

.issue-card p:nth-child(2) {
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
  color: #0f172a;
}

.student-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 0.58fr);
  gap: 20px;
  align-items: center;
  min-height: 48px;
  padding: 0 34px;
  border-bottom: 1px solid #d5e1ee;
  background: #fbfdff;
}

.student-strip p {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  color: #2f4057;
  font-size: 0.92rem;
  font-weight: 800;
}

.student-strip p::after {
  content: "";
  border-bottom: 1.5px solid #27384a;
  transform: translateY(-3px);
}

.activity-instructions {
  padding: 14px 34px 0;
  color: #29384a;
  font-size: 0.9rem;
  line-height: 1.45;
  text-align: center;
}

.activity-instructions h3 {
  margin: 0 0 5px;
  color: #0f172a;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.15;
}

.mandala-grid {
  display: grid;
  gap: 18px;
  padding: 18px 34px 12px;
}

.layout-one {
  grid-template-columns: 1fr;
}

.mandala-card {
  min-width: 0;
  display: grid;
  place-items: center;
  border: 1px solid #d5e1ee;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.layout-one .mandala-card {
  width: min(75%, 610px);
  aspect-ratio: 1 / 1;
  justify-self: center;
  min-height: 0;
  padding: 10px;
}

.mandala-card img {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.mandala-card img[data-src] {
  opacity: 0;
}

.mandala-card img.is-ready {
  opacity: 1;
}

.mandala-card.no-frame {
  border-color: transparent;
  background: #ffffff;
}

.activity-addon {
  padding: 0 34px 22px;
}

.addon-card {
  min-height: 104px;
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border: 1px solid #d5e2f0;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(244, 154, 33, 0.07), transparent 42%),
    #ffffff;
  color: #17324d;
}

.addon-card strong {
  color: #0f172a;
  font-size: 0.94rem;
  font-weight: 900;
}

.palette-line,
.pattern-grid span {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
}

.color-dot {
  width: 26px;
  height: 26px;
  display: inline-block;
  border-radius: 999px;
  background: var(--swatch);
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(23, 48, 77, 0.18), 0 8px 15px rgba(23, 48, 77, 0.08);
}

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

.pattern-grid span,
.temperature-card > div,
.choice-row span,
.title-line,
.symmetry-guide {
  border: 1px solid #d5e2f0;
  border-radius: 8px;
  background: #fbfdff;
}

.pattern-grid span {
  justify-content: center;
  min-height: 44px;
  padding: 8px;
}

.temperature-card {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.temperature-card > div {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.symmetry-card {
  grid-template-columns: 180px minmax(0, 1fr);
}

.symmetry-guide {
  position: relative;
  min-height: 62px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 12px 24px;
}

.symmetry-guide i {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 50%;
  border-left: 3px solid var(--accent);
}

.symmetry-guide span {
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #ffffff;
  border: 3px solid #f49a21;
  color: #f49a21;
  font-weight: 900;
}

.symmetry-guide .mirror-b {
  border-color: #24856b;
  color: #24856b;
}

.symmetry-guide .mirror-a {
  border-color: #f49a21;
  color: #f49a21;
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.choice-row span {
  min-height: 52px;
  display: grid;
  place-items: center;
  color: #6b7a8d;
  font-size: 1rem;
  font-weight: 900;
}

.title-card {
  grid-template-columns: 190px minmax(0, 1fr);
}

.title-line {
  min-height: 54px;
  border: 0;
  border-bottom: 2px solid #17324d;
  border-radius: 0;
  background: transparent;
}

.worksheet-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-top: auto;
  padding: 12px 34px 14px;
  border-top: 1px solid #d1dbe7;
  background: #f8fafc;
  color: #59687a;
  font-size: 0.78rem;
  font-weight: 800;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .worksheet-masthead,
  .student-strip {
    display: grid;
  }

  .worksheet-footer {
    display: grid;
    padding-inline: 14px;
  }

  .layout-one .mandala-card {
    width: 100%;
  }

  .pattern-grid,
  .temperature-card,
  .symmetry-card,
  .title-card {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html,
  body {
    width: 210mm;
    min-height: 297mm;
    background: #fff;
  }

  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .control-panel {
    display: none;
  }

  .app-shell {
    padding: 0;
  }

  .workspace,
  .activity-panel {
    display: block;
    width: 210mm;
    max-width: none;
    margin: 0;
  }

  .worksheet {
    width: 210mm;
    height: 297mm;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .worksheet-masthead {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 118pt;
    column-gap: 18pt;
    align-items: center;
    min-height: 78pt;
    padding: 13pt 42pt 10pt;
    border-top: 8pt solid var(--brand-orange);
    border-bottom: 1pt solid #c7d6e6;
  }

  .masthead-brand {
    display: grid !important;
    grid-template-columns: 50pt minmax(0, 1fr);
    gap: 14pt;
  }

  .worksheet-logo {
    width: 50pt;
    height: 50pt;
    box-shadow: none;
  }

  .worksheet-kicker {
    font-size: 8pt;
  }

  #worksheet-title {
    max-width: 300pt;
    overflow: hidden;
    font-size: 25pt;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .issue-card {
    box-sizing: border-box;
    justify-self: end;
    align-self: center;
    width: 118pt;
    min-width: 118pt;
    padding: 7pt 0 7pt 12pt;
    border-left: 3pt solid var(--accent);
    background: transparent;
    text-align: right;
  }

  .issue-card p {
    margin: 0;
    white-space: nowrap;
    font-size: 8pt !important;
    font-weight: 700 !important;
  }

  .issue-card p:empty {
    display: none !important;
  }

  .issue-card p:nth-child(2) {
    font-size: 15pt !important;
    font-weight: 900 !important;
  }

  .student-strip {
    height: 28pt;
    padding: 0 42pt;
    align-items: center;
    font-size: 9pt;
  }

  .activity-instructions {
    padding: 9pt 42pt 0;
    font-size: 11.2pt;
    line-height: 1.22;
  }

  .activity-instructions h3 {
    margin-bottom: 3pt;
    font-size: 12.5pt;
  }

  .mandala-grid {
    gap: 14pt;
    padding: 10pt 42pt 7pt;
  }

  .layout-one {
    grid-template-columns: 1fr;
  }

  .layout-one .mandala-card {
    justify-self: center;
    width: 112mm;
    min-height: 0;
    height: 112mm;
    padding: 5pt;
  }

  .mandala-card {
    border-radius: 4pt;
    box-shadow: none;
  }

  .activity-addon {
    padding: 0 42pt 8pt;
  }

  .addon-card {
    min-height: 72pt;
    gap: 8pt;
    padding: 10pt 14pt;
    border-radius: 4pt;
  }

  .addon-card strong {
    font-size: 9pt;
  }

  .color-dot {
    width: 15pt;
    height: 15pt;
    border-width: 2pt;
    box-shadow: 0 0 0 0.6pt rgba(23, 48, 77, 0.18);
  }

  .pattern-grid {
    gap: 8pt;
  }

  .pattern-grid span,
  .temperature-card > div,
  .choice-row span,
  .symmetry-guide {
    min-height: 34pt;
    border-radius: 4pt;
  }

  .choice-row span {
    min-height: 38pt;
  }

  .worksheet-footer {
    padding: 8pt 42pt 9pt;
    font-size: 7.6pt;
  }
}
