/* Return of Corrections: Form BC 1. Every corner square, every rule a hairline. */

*, *::before, *::after { box-sizing: border-box; border-radius: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
}

p { margin: 0; }

.page {
  width: min(72rem, 100% - 32px);
  margin: 0 auto;
  padding: 28px 0 40px;
}

/* header */
.head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--ink);
}
h1 {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.15;
  font-weight: var(--fw-bold);
  letter-spacing: -0.01em;
}
.rule {
  width: 180px;
  max-width: 100%;
  height: 6px;
  margin-top: 10px;
  background: var(--c-brick);
}
.formno {
  font-size: 16px;
  white-space: nowrap;
  padding-top: 0.45rem;
  font-variant-numeric: tabular-nums;
}

/* layout: the house grid of 32 columns, writing 1 to 15, the Return 17 to 32 */
.grid { padding-top: 24px; }
.writing, .ret { min-width: 0; }
.ret { margin-top: 40px; }
@media (min-width: 900px) {
  .grid { display: grid; grid-template-columns: repeat(32, minmax(0, 1fr)); }
  .writing { grid-column: 1 / 16; }
  .ret { grid-column: 17 / 33; margin-top: 0; }
}

/* writing */
.intro { margin-bottom: 18px; }
.boxlabel {
  display: block;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
#box {
  display: block;
  width: 100%;
  min-height: 26rem;
  padding: 12px 14px;
  font: inherit;
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--ink);
  resize: vertical;
}
@media (max-width: 899px) { #box { min-height: 16rem; } }
.sound { margin-top: 14px; }
.soundlabel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.soundlabel input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--ink);
}
.note {
  font-size: 0.875rem;
  color: var(--ink-soft);
}
.sound .note { margin-top: 4px; }

/* the Return */
.sheet {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ink);
  font-variant-numeric: tabular-nums;
}
#sheetno { font-weight: var(--fw-bold); }
.nav { display: flex; gap: 8px; }

button {
  font: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  padding: 5px 12px;
  cursor: pointer;
}
button:active, button:focus-visible {
  background: var(--accent);
  color: var(--accent-fg);
}
button:disabled {
  color: var(--ink-soft);
  border-color: var(--ink-soft);
  background: transparent;
  cursor: default;
}
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
#box:focus { outline: 2px solid var(--ink); outline-offset: 2px; }

table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; font-weight: normal; padding: 0; }

.summary { margin-top: 4px; }
.summary th, .summary td {
  padding: 5px 0;
  border-bottom: 1px solid var(--ink-soft);
  vertical-align: baseline;
}
.summary th { width: 50%; }
.summary .sub { margin-left: 0.75em; }

.counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0 20px;
  margin-top: 24px;
}
.panel { table-layout: fixed; }
.panel col.c-no { width: 1.75rem; }
.panel col.c-letter { width: 3.4rem; }
.panel col.c-note { width: 2.8rem; }
.panel col.c-times { width: 3.4rem; }
.panel thead th {
  font-size: 0.8125rem;
  white-space: nowrap;
  color: var(--ink);
  font-weight: var(--fw-bold);
  padding: 0 0 4px;
  border-bottom: 1px solid var(--ink);
}
.panel tbody th, .panel tbody td {
  height: 1.6rem;
  padding: 0;
  border-bottom: 1px solid var(--ink-soft);
  vertical-align: middle;
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
}
.panel .no { color: var(--ink-soft); font-size: 0.8125rem; }
.panel .tally { padding-right: 2px; }
.tally svg { display: block; width: 100%; height: 14px; }
.tally .s { stroke: var(--ink); stroke-width: 1.6; stroke-linecap: square; }
.tally .g { stroke: var(--c-brick); stroke-width: 1.7; stroke-linecap: square; }

.tape {
  margin-top: 24px;
  padding: 10px 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.tape .ch { color: var(--error); }

.wav { margin-top: 20px; }
.wavrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.wav > .note { margin-top: 6px; }
#clear { margin-top: 18px; }

/* footer */
.foot {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 48px;
  padding-top: 14px;
  border-top: 1px solid var(--ink-soft);
  font-size: 0.8125rem;
  color: var(--ink-soft);
}
.wordmark { height: 18px; width: auto; flex: none; margin-top: 1px; }
.footlines p + p { margin-top: 4px; }
@media (max-width: 600px) { .foot { flex-direction: column; gap: 8px; } }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wordmark { background: var(--c-cream); padding: 4px; height: 26px; }
}

/* print: the displayed sheet alone, one A4 page */
@page { size: A4; margin: 14mm; }
@media print {
  :root:not([data-theme="light"]) {
    --ink: #1A1A1A;
    --ink-soft: #5B5B5B;
    --error: #BE3B27;
  }
  body { background: none; font-size: 11pt; }
  .page { width: auto; padding: 0; }
  .writing, .intro, .sound, .nav, .wav, .foot { display: none; }
  .grid { display: block; padding-top: 14px; }
  .ret { margin-top: 0; }
  h1 { font-size: 18pt; }
  .counts { grid-template-columns: 1fr 1fr; margin-top: 14px; }
  .panel tbody th, .panel tbody td { height: 1.45rem; }
  .tape { margin-top: 14px; line-height: 1.45; }
  tr, .panel, .summary, .tape { break-inside: avoid; }
}
