:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #9a9a9a;
  --faint: #c8c8c8;
  --rule: #ececec;

  /* Vowel sounds: front vowels warm, back vowels cool, diphthongs in between */
  --IY: #fbd6d3; --IH: #fce4d6; --EY: #fcecd0; --EH: #f8f1c8; --AE: #e8f3cc;
  --AY: #d6efd6; --AA: #d2eee6; --AO: #d2ebf3; --OW: #d8e5fa; --UH: #dfdff9;
  --UW: #e9dcf8; --OY: #dde4ea; --AW: #f3d6f0; --ER: #f1e3d2; --AH: #e4ddcf;
  --schwa: #f2f2f2;
  --serif: "EB Garamond", Garamond, "Times New Roman", serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.5 var(--serif);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* ---------- Workspace ---------- */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 40px 40px;
}

.stats {
  display: flex;
  align-items: baseline;
  gap: 20px;
  font-variant-numeric: tabular-nums lining-nums;
}
.stat-value { font-size: 1rem; }
.stat-label { font-size: .85rem; font-style: italic; color: var(--muted); }
.stat-main .stat-value { font-size: 1.35rem; }

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pane + .pane { border-left: 1px solid var(--rule); }

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 44px;
  padding: 0 24px;
}
.pane:first-child .pane-head { padding-left: 0; }
.status { font-size: .85rem; font-style: italic; color: var(--faint); }

button {
  font: inherit;
  font-size: .85rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
button:hover { color: var(--text); }
kbd { font: inherit; margin-left: 4px; color: var(--faint); }
button:focus-visible { outline: 1px solid var(--text); outline-offset: 4px; }

textarea {
  flex: 1;
  width: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  outline: none;
  padding: 4px 24px 24px 0;
  background: transparent;
  color: var(--text);
  font: 21px/2 var(--serif);
}
textarea::placeholder { color: var(--faint); }

/* ---------- Output ---------- */
.output {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 4px 0 24px;
  font-size: 21px;
}

.line {
  display: grid;
  grid-template-columns: 3.25em 1fr;
  align-items: baseline;
  min-height: 2em;
}

.count {
  justify-self: end;
  padding-right: 1em;
  color: var(--muted);
  font-size: .8em;
  font-variant-numeric: tabular-nums lining-nums;
  user-select: none;
}
.count.zero { color: var(--faint); }
.count.empty { visibility: hidden; }

.content {
  padding-right: 24px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 2;
}

.word {
  display: inline-flex;
  gap: 2px;
  white-space: nowrap;
}
.syl {
  display: inline-block;
  padding: 0 .22em;
  border-radius: 4px;
  line-height: 1.6;
}
.v-IY { --v: var(--IY); }
.v-IH { --v: var(--IH); }
.v-EY { --v: var(--EY); }
.v-EH { --v: var(--EH); }
.v-AE { --v: var(--AE); }
.v-AY { --v: var(--AY); }
.v-AA { --v: var(--AA); }
.v-AO { --v: var(--AO); }
.v-OW { --v: var(--OW); }
.v-UH { --v: var(--UH); }
.v-UW { --v: var(--UW); }
.v-OY { --v: var(--OY); }
.v-AW { --v: var(--AW); }
.v-ER { --v: var(--ER); }
.v-AH { --v: var(--AH); }
.v-schwa { --v: var(--schwa); }
[class*="v-"] { background: var(--v); }
/* Unstressed syllables: same hue, paler */
.syl.weak { background: color-mix(in srgb, var(--v) 45%, #fff); }
.v-unknown { background: none; box-shadow: inset 0 0 0 1px var(--rule); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 0 0 68px;
  border-top: 1px solid var(--rule);
  font-size: 15px;
}
.legend .syl { color: #555; }

.placeholder {
  color: var(--faint);
  padding-left: 3.25em;
  font-size: 21px;
  line-height: 2;
}

/* ---------- Small screens ---------- */
@media (max-width: 820px) {
  body { height: auto; }
  .stats { gap: 14px; }
  .workspace { grid-template-columns: 1fr; padding: 16px 20px 28px; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--rule); }
  .pane-head { padding: 0; }
  textarea { min-height: 30vh; padding-right: 0; }
  .output { min-height: 30vh; }
  .line { grid-template-columns: 2.25em 1fr; }
  .placeholder { padding-left: 2.25em; }
  .legend { padding-left: 0; }
  .content { padding-right: 0; }
}
