/* Fixed US Letter worksheet layout */
:root {
  --ink: #1a1a2e;
  --muted: #5a6480;
  --navy: #1a2a5e;
  --blue: #1e4fa0;
  --teal: #1a6b73;
  --line: #cbd5e1;
  --soft: #f7f9fc;
  --page-width: 8.5in;
  --page-height: 11in;
  --page-margin: 0.6in;
}

* {
  box-sizing: border-box;
}

@page {
  size: letter;
  margin: var(--page-margin);
}

html,
body {
  margin: 0;
  padding: 0;
  color: var(--ink);
  background: #e8edf5;
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 11pt;
  line-height: 1.4;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: var(--navy);
  color: #fff;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.toolbar p {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.92;
}

.toolbar-actions {
  display: flex;
  gap: 0.5rem;
}

.toolbar button {
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  background: #fff;
  color: var(--navy);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.45rem 0.9rem;
}

.sheet {
  width: var(--page-width);
  min-height: var(--page-height);
  margin: 1rem auto;
  padding: var(--page-margin);
  background: #fff;
  box-shadow: 0 8px 28px rgba(26, 42, 94, 0.12);
}

header.sheet-header {
  margin-bottom: 0.9rem;
  padding-bottom: 0.65rem;
  border-bottom: 2px solid var(--navy);
}

.eyebrow {
  margin: 0 0 0.3rem;
  color: var(--teal);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 0.35rem;
  color: var(--navy);
  font-size: 1.45rem;
  line-height: 1.15;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

h2 {
  margin: 0 0 0.45rem;
  color: var(--blue);
  font-size: 1.1rem;
  break-after: avoid;
  page-break-after: avoid;
}

h3 {
  margin: 0.7rem 0 0.35rem;
  color: var(--teal);
  font-size: 0.98rem;
  break-after: avoid;
  page-break-after: avoid;
}

p,
ul,
ol {
  margin: 0 0 0.5rem;
}

ul,
ol {
  padding-left: 1.15rem;
}

li {
  margin-bottom: 0.2rem;
}

.meta-fields {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0.4rem 0 0.7rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.meta-row {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  border-top: 1px solid var(--line);
}

.meta-row:first-child {
  border-top: none;
}

.meta-label {
  margin: 0;
  padding: 0.55rem 0.65rem;
  background: var(--soft);
  color: var(--navy);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.3;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--line);
}

.meta-write {
  min-height: 3.25rem;
  padding: 0.45rem 0.55rem;
  background: #fff;
}

.meta-hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

.meta,
.summary,
.score-table,
.work-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.4rem 0 0.7rem;
  font-size: 0.9rem;
}

.meta th,
.meta td,
.summary th,
.summary td,
.score-table th,
.score-table td,
.work-table th,
.work-table td {
  border: 1px solid var(--line);
  padding: 0.55rem 0.55rem;
  vertical-align: top;
  text-align: left;
}

.summary td,
.work-table td {
  height: 2.75rem;
}

.summary td:last-child,
.work-table td:last-child {
  height: 3.25rem;
}

.meta th,
.summary th,
.score-table th,
.work-table th {
  background: var(--soft);
  color: var(--navy);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  height: auto;
}

.write-line {
  display: block;
  min-height: 1.75rem;
  border-bottom: 1px dotted #94a3b8;
}

.write-box {
  min-height: 2.4in;
  margin-top: 0.3rem;
  border: 1.5px solid var(--line);
  border-radius: 4px;
  background:
    repeating-linear-gradient(
      transparent,
      transparent calc(0.3in - 1px),
      #e2e8f0 calc(0.3in - 1px),
      #e2e8f0 0.3in
    );
}

.write-box.tall {
  min-height: 3.2in;
}

.check-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.55rem;
}

.check-list li {
  display: grid;
  grid-template-columns: 1rem 1fr;
  gap: 0.5rem;
  align-items: start;
  margin-bottom: 0.35rem;
  break-inside: avoid;
  page-break-inside: avoid;
}

.check-list input[type="checkbox"] {
  margin-top: 0.15rem;
  width: 0.95rem;
  height: 0.95rem;
}

.section {
  margin-bottom: 0.25rem;
}

/* Major sections start on a new Letter page */
.section.page-start {
  break-before: page;
  page-break-before: always;
}

.notes-block {
  margin-top: 0.45rem;
  break-inside: avoid;
  page-break-inside: avoid;
}

.notes-block label {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
}

.footer-note {
  margin-top: 1rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

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

  .toolbar {
    display: none !important;
  }

  .sheet {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}
