@font-face {
  font-family: "Montserrat";
  src: url("assets/Montserrat-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("assets/Montserrat-Bold.ttf") format("truetype");
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #111827;
  --muted: #64748b;
  --panel: #eef3f8;
  --paper: #ffffff;
  --line: #d5e2f0;
  --accent: #235f9f;
  --accent-dark: #174876;
  --brand-orange: #f49a21;
  --brand-green: #24856b;
  --teal: #1b8c78;
  --violet: #7c5cc4;
  --rose: #d84d89;
  --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;
}

.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-size: 0.86rem;
  font-weight: 700;
}

select,
input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--ink);
  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;
}

.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 {
  min-height: 120px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  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 {
  min-width: 0;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

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

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

#worksheet-title {
  margin-top: 3px;
  color: #111827;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 0.98;
  font-weight: 900;
}

.issue-card {
  min-width: 220px;
  padding: 12px 0 12px 18px;
  border-left: 4px solid var(--accent);
  text-align: right;
}

.issue-card p {
  color: #111827;
  font-size: 0.9rem;
  font-weight: 700;
}

.issue-card p:nth-child(2) {
  margin-top: 5px;
  font-size: 1.35rem;
  font-weight: 900;
}

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

.student-strip {
  min-height: 46px;
  display: grid;
  grid-template-columns: 1fr 0.55fr;
  gap: 24px;
  align-items: center;
  padding: 0 34px;
  border-bottom: 1px solid #d7e2ee;
  color: #203247;
  font-size: 1rem;
  font-weight: 900;
}

.student-strip p {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: end;
}

.student-strip p::after {
  content: "";
  display: block;
  border-bottom: 1.5px solid #203247;
  transform: translateY(-5px);
}

.activity-instructions {
  padding: 16px 34px 6px;
  text-align: center;
  color: #172033;
  font-size: 0.86rem;
  line-height: 1.45;
}

.clock-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  padding: 14px 34px 18px;
}

.clock-card {
  position: relative;
  min-height: 176px;
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 18px 18px 16px 20px;
  border: 1px solid #cdddeb;
  border-left: 6px solid var(--card-color);
  border-radius: 8px;
  background:
    linear-gradient(100deg, var(--card-soft), rgba(255, 255, 255, 0.96) 46%),
    #fff;
  box-shadow: 0 12px 28px rgba(22, 35, 52, 0.06);
}

.count-8 .clock-card {
  min-height: 142px;
  grid-template-columns: 102px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 14px 12px 16px;
}

.clock-number {
  position: absolute;
  top: 12px;
  left: 14px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--card-color);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 900;
}

.clock-figure {
  width: 120px;
  height: 120px;
  margin-left: 6px;
}

.count-8 .clock-figure {
  width: 96px;
  height: 96px;
}

.clock-figure svg {
  width: 100%;
  height: 100%;
  display: block;
}

.clock-card.is-routine {
  grid-template-columns: 108px 82px minmax(0, 1fr);
  gap: 10px;
}

.count-8 .clock-card.is-routine {
  grid-template-columns: 78px 62px minmax(0, 1fr);
  gap: 7px;
}

.is-routine .clock-figure {
  width: 104px;
  height: 104px;
  margin-left: 0;
}

.count-8 .is-routine .clock-figure {
  width: 74px;
  height: 74px;
}

.routine-figure {
  width: 82px;
  height: 70px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #d8e3ed;
  border-radius: 7px;
  background: #fff;
}

.routine-figure img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.count-8 .routine-figure {
  width: 62px;
  height: 54px;
}

.is-routine .clock-copy {
  gap: 5px;
}

.is-routine .clock-task {
  font-size: 0.94rem;
}

.clock-copy {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.clock-task {
  color: #0f1b2d;
  font-size: 1.02rem;
  font-weight: 900;
  line-height: 1.2;
}

.digital-time {
  color: var(--accent-dark);
  font-size: 1.65rem;
  line-height: 1;
  font-weight: 900;
}

.routine-label {
  color: var(--brand-green);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.answer-line {
  min-height: 28px;
  display: flex;
  align-items: end;
  border-bottom: 2px solid #17324d;
  color: var(--accent-dark);
  font-size: 1.05rem;
  font-weight: 900;
}

.count-8 .answer-line {
  min-height: 22px;
  font-size: 0.92rem;
}

.worksheet-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  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: 680px) {
  .app-shell {
    padding: 12px;
  }

  .worksheet-masthead,
  .student-strip,
  .clock-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .issue-card {
    width: 100%;
    min-width: 0;
    text-align: left;
  }

  .clock-card,
  .count-8 .clock-card {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .clock-card.is-routine,
  .count-8 .clock-card.is-routine {
    grid-template-columns: 82px 68px minmax(0, 1fr);
  }

  .is-routine .clock-figure,
  .count-8 .is-routine .clock-figure {
    width: 78px;
    height: 78px;
  }

  .routine-figure,
  .count-8 .routine-figure {
    width: 66px;
    height: 58px;
  }
}

@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: 330pt;
    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:nth-child(2) {
    font-size: 15pt !important;
    font-weight: 900 !important;
  }

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

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

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

  .clock-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8pt 11pt;
    padding: 11pt 42pt 8pt;
  }

  .clock-card {
    min-height: 128pt;
    grid-template-columns: 86pt minmax(0, 1fr);
    gap: 8pt;
    padding: 12pt 11pt 10pt 14pt;
    border-radius: 4pt;
    box-shadow: none;
  }

  .count-4 .clock-card {
    min-height: 178pt;
    grid-template-columns: 106pt minmax(0, 1fr);
  }

  .count-8 .clock-card {
    min-height: 90pt;
    grid-template-columns: 66pt minmax(0, 1fr);
    gap: 7pt;
    padding: 8pt 10pt 7pt 12pt;
  }

  .clock-card.is-routine {
    grid-template-columns: 68pt 54pt minmax(0, 1fr);
    gap: 5pt;
  }

  .count-4 .clock-card.is-routine {
    grid-template-columns: 88pt 70pt minmax(0, 1fr);
  }

  .count-8 .clock-card.is-routine {
    grid-template-columns: 50pt 42pt minmax(0, 1fr);
    gap: 4pt;
  }

  .clock-number {
    top: 8pt;
    left: 8pt;
    width: 21pt;
    height: 21pt;
    font-size: 8pt;
  }

  .clock-figure {
    width: 82pt;
    height: 82pt;
    margin-left: 0;
  }

  .count-4 .clock-figure {
    width: 101pt;
    height: 101pt;
  }

  .count-8 .clock-figure {
    width: 64pt;
    height: 64pt;
  }

  .is-routine .clock-figure {
    width: 66pt;
    height: 66pt;
  }

  .count-4 .is-routine .clock-figure {
    width: 84pt;
    height: 84pt;
  }

  .count-8 .is-routine .clock-figure {
    width: 48pt;
    height: 48pt;
  }

  .routine-figure {
    width: 52pt;
    height: 46pt;
    border-radius: 3pt;
  }

  .count-4 .routine-figure {
    width: 68pt;
    height: 58pt;
  }

  .count-8 .routine-figure {
    width: 40pt;
    height: 36pt;
  }

  .clock-copy {
    gap: 5pt;
  }

  .clock-task {
    font-size: 9.6pt;
  }

  .digital-time {
    font-size: 15pt;
  }

  .routine-label {
    font-size: 7pt;
  }

  .is-routine .clock-task {
    font-size: 8.5pt;
  }

  .answer-line {
    min-height: 20pt;
    font-size: 9pt;
  }

  .count-8 .answer-line {
    min-height: 14pt;
    font-size: 8pt;
  }

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