.lab-page .main { max-width: 820px; }
.lab-page--wide .main { max-width: 980px; }

.lab-page .kicker a { color: inherit; text-decoration: none; }
.lab-page .kicker a:hover,
.lab-page .kicker a:focus-visible { text-decoration: underline; text-underline-offset: 3px; }

.field {
  display: block;
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--muted);
}

.lab-page textarea {
  display: block;
  width: 100%;
  min-height: 9rem;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
}

.lab-page textarea:focus-visible,
.lab-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lab-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 0 16px;
}

.lab-langs { margin-bottom: 4px; }
.lab-kinds { margin-top: 0; }

.lab-hint {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
}

.lab-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  margin: 0;
  padding: 7px 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
}

.lab-btn:hover { border-color: var(--accent); color: var(--accent); }
.lab-btn[aria-pressed="true"] {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--on-accent);
}
.lab-btn[aria-pressed="true"]:hover {
  background: var(--accent-fill-hover);
  border-color: var(--accent-fill-hover);
  color: var(--on-accent);
}

.lab-note {
  margin: 0 0 28px;
  font-size: 14px;
  color: var(--muted);
}

.is-hidden { display: none; }

/* Poem to code */
.lang-bar { margin: 0 0 18px; }
.lang-bar .hint {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}
.lang-bar .lab-row {
  margin: 0 0 8px;
}
.lang-bar .lab-row:last-child {
  margin-bottom: 0;
}
.lab-label {
  min-width: 8.5rem;
  font-size: 14px;
  color: var(--muted);
}

.verse-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 0 0 16px;
  align-items: stretch;
}

.verse-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 16px 16px 14px;
}

.verse-panel h2 {
  margin: 0 0 8px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.verse-panel .hint {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

.verse-panel textarea {
  height: 11.5rem;
  min-height: 11rem;
  background: var(--bg);
}

.verse-panel .lab-row {
  margin: 10px 0;
}

.out {
  flex: 1 1 auto;
  margin: 0;
  min-height: 11rem;
  padding: 10px 12px;
  overflow: auto;
  border: 1px solid var(--line);
  background: #0f3d4c;
  color: #f4f1ea;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

:root[data-theme="dark"] .out {
  background: var(--wash);
  color: var(--code-ink);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .out {
    background: var(--wash);
    color: var(--code-ink);
  }
}

.out.is-empty { color: #b7c6cb; }

.verse-panel .verse-note {
  margin: 10px 0 0;
}

/* The meter of code */
#code-in.meter-in {
  min-height: 9rem;
}

.meter-empty {
  margin: 0 0 20px;
  color: var(--muted);
}

.meter-fig {
  margin: 0 0 16px;
  padding: 12px 12px 8px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.meter-fig svg { display: block; width: 100%; height: auto; }
.meter-legend {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}

.meter-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}
.meter-stats div {
  margin: 0;
  padding: 12px 14px;
  background: var(--wash);
  border-left: 3px solid var(--accent);
}
.meter-stats dt {
  margin: 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.meter-stats dd { margin: 4px 0 0; font-size: 16px; }
.rhythm-name {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.rhythm-why { margin: 0; font-size: 16px; color: var(--muted); }

.meter-lines {
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
  max-height: 220px;
  overflow: auto;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
.meter-lines li { margin: 0; padding: 2px 0; }

@media (min-width: 861px) {
  .verse-panel > .hint:first-of-type {
    min-height: 2.95em;
  }
}

@media (max-width: 860px) {
  .verse-pair { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .lab-label { min-width: 100%; }
  .lab-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 14px;
  }
}

/* Theme-aware SVG bars & dots for The meter of code */
.meter-bar--neutral { fill: #c4bdb2; }
.meter-bar--r0, .meter-dot--m0 { fill: #0f3d4c; }
.meter-bar--r1, .meter-dot--m1 { fill: #c45c26; }
.meter-bar--r2, .meter-dot--m2 { fill: #3d6b4f; }
.meter-bar--r3, .meter-dot--m3 { fill: #6b4a2f; }
.meter-bar--r4, .meter-dot--m4 { fill: #3a4a6b; }
.meter-bar--r5, .meter-dot--m5 { fill: #7a4e62; }

:root[data-theme="dark"] .meter-bar--neutral { fill: #6e7b84; }
:root[data-theme="dark"] .meter-bar--r0, :root[data-theme="dark"] .meter-dot--m0 { fill: #6ab7c9; }
:root[data-theme="dark"] .meter-bar--r1, :root[data-theme="dark"] .meter-dot--m1 { fill: #e07a47; }
:root[data-theme="dark"] .meter-bar--r2, :root[data-theme="dark"] .meter-dot--m2 { fill: #7bc496; }
:root[data-theme="dark"] .meter-bar--r3, :root[data-theme="dark"] .meter-dot--m3 { fill: #d8a572; }
:root[data-theme="dark"] .meter-bar--r4, :root[data-theme="dark"] .meter-dot--m4 { fill: #8faee8; }
:root[data-theme="dark"] .meter-bar--r5, :root[data-theme="dark"] .meter-dot--m5 { fill: #d293b3; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .meter-bar--neutral { fill: #6e7b84; }
  :root:not([data-theme="light"]) .meter-bar--r0, :root:not([data-theme="light"]) .meter-dot--m0 { fill: #6ab7c9; }
  :root:not([data-theme="light"]) .meter-bar--r1, :root:not([data-theme="light"]) .meter-dot--m1 { fill: #e07a47; }
  :root:not([data-theme="light"]) .meter-bar--r2, :root:not([data-theme="light"]) .meter-dot--m2 { fill: #7bc496; }
  :root:not([data-theme="light"]) .meter-bar--r3, :root:not([data-theme="light"]) .meter-dot--m3 { fill: #d8a572; }
  :root:not([data-theme="light"]) .meter-bar--r4, :root:not([data-theme="light"]) .meter-dot--m4 { fill: #8faee8; }
  :root:not([data-theme="light"]) .meter-bar--r5, :root:not([data-theme="light"]) .meter-dot--m5 { fill: #d293b3; }
}
