.ending-template {
  --ending-ink: var(--learn-ink, var(--atlas-ink, #152b4b));
  --ending-blue: var(--learn-primary, var(--atlas-blue, #075f85));
  --ending-muted: var(--learn-muted, var(--atlas-muted, #46677a));
  --ending-border: var(--learn-line, var(--atlas-line, #cce4ed));
  --ending-soft: #f2f9fc;
  --ending-accent: #d8edf5;
  --ending-selected: var(--learn-mint, #e1f4eb);
  --ending-green: var(--learn-mint-ink, #195f47);
  --ending-latin: Inter, Arial, sans-serif;
  container-type: inline-size;
  display: grid;
  gap: 16px;
  min-inline-size: 0;
  padding: 16px;
  border: 1px solid var(--ending-border);
  border-radius: 24px;
  background: #fff;
  color: var(--ending-ink);
}

.ending-template :is(h3, h4, h5, p, ul, details) { margin: 0; }
.ending-template p { font-size: 14px; line-height: 24px; }
.ending-template h4,
.ending-template .ending-template-feature h5,
.ending-template-group h5 {
  color: var(--ending-blue);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.5;
}

.ending-template-intro { display: grid; gap: 4px; }
.ending-template .ending-template-intro h3 {
  color: var(--ending-ink);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.5;
}
.ending-template .ending-template-kicker {
  color: var(--ending-blue);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
}
.ending-template .ending-template-context { color: var(--ending-muted); }

.ending-template-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ending-template-choices button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 4px;
  min-height: 68px;
  border: 1px solid var(--ending-border);
  border-radius: 12px;
  background: var(--ending-soft);
  color: var(--ending-ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
}

.ending-template-choices button[aria-pressed="true"] {
  border-color: var(--ending-green);
  background: var(--ending-selected);
  color: var(--ending-green);
  box-shadow: inset 0 0 0 1px var(--ending-green);
}

.ending-template-choices button:focus-visible,
.ending-template summary:focus-visible {
  outline: 2px solid var(--ending-blue);
  outline-offset: 2px;
}

.ending-template-choices strong {
  color: var(--ending-blue);
  font: 700 22px / 28px var(--ending-latin);
}
.ending-template-choices button[aria-pressed="true"] strong { color: inherit; }

.ending-template-panel,
.ending-template-groups,
.ending-template-group,
.ending-template-example-layout,
.ending-template-extra {
  display: grid;
  min-width: 0;
}

.ending-template-panel,
.ending-template-groups,
.ending-template-example-layout { gap: 12px; }
.ending-template-group,
.ending-template-extra { gap: 8px; }
.ending-template-group > p { white-space: pre-line; }
.ending-template-panel[hidden] { display: none; }

.ending-template-panel,
.ending-template-group:not(.ending-template-worked) {
  padding: 12px;
  border: 1px solid var(--ending-border);
  background: var(--ending-soft);
}
.ending-template-panel { border-radius: 16px; }
.ending-template-group:not(.ending-template-worked) { border-radius: 12px; }

.ending-template-group + .ending-template-group { background: #f0f8f3; }
.ending-template-group + .ending-template-group h5 { color: var(--ending-green); }
.ending-template-extra h5 {
  color: var(--ending-blue);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
}

.ending-template .ending-template-endings {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  padding: 0;
  list-style: none;
}
.ending-template-endings li {
  padding: 6px 7px;
  border-radius: 8px;
  background: var(--ending-accent);
  color: var(--ending-blue);
  font: 700 19px / 26px var(--ending-latin);
}

.ending-template .ending-template-vowels {
  color: var(--ending-green);
  font: 700 22px / 28px var(--ending-latin);
  word-spacing: .28em;
}

.ending-template .ending-template-examples {
  display: grid;
  gap: 8px;
  padding: 0;
  list-style: none;
}

.ending-template-example {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--ending-border);
  border-radius: 12px;
  background: #fff;
}
.ending-template-feature { gap: 8px; padding: 16px; }

.ending-template-word,
.ending-template-sentence {
  text-align: left;
  overflow-wrap: anywhere;
}

.ending-template .ending-template-word {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--ending-ink);
  font: 500 14px / 28px var(--ending-latin);
}
.ending-template-word strong { font-size: 22px; font-weight: 700; }
.ending-template-feature .ending-template-word { gap: 6px; font-size: 22px; font-weight: 700; }
.ending-template-feature .ending-template-word strong { font-size: inherit; }
.ending-template-feature .ending-template-word :is(.ending-template-base, strong) {
  display: inline-block;
  padding: 7px 8px;
  border-radius: 8px;
}
.ending-template-feature .ending-template-base { background: var(--ending-accent); }
.ending-template-feature .ending-template-word strong { background: var(--ending-selected); }

.ending-template .ending-template-sentence { font: 500 14px / 22px var(--ending-latin); }
.ending-template :is(.ending-template-translation, .ending-template-note) { color: var(--ending-muted); }
.ending-template .ending-template-before {
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--ending-soft);
}
.ending-template-short-answer {
  display: grid;
  gap: 4px;
  padding: 8px;
  border-radius: 8px;
  background: var(--ending-selected);
}

.ending-template-example mark {
  padding: 0;
  background: transparent;
  color: var(--ending-green);
  font-weight: 800;
}
.ending-template-example mark.ending-template-cue {
  border-radius: 3px;
  background: var(--ending-accent);
  color: var(--ending-blue);
}

@media (max-width: 359px) {
  .ending-template-feature .ending-template-word { font-size: 20px; }
}

@media (min-width: 768px) {
  .ending-template { padding: 24px; }

  @container (min-width: 580px) {
    .ending-template .ending-template-intro h3 { font-size: 36px; }
    .ending-template-panel { padding: 20px; }
    .ending-template-groups:has(> .ending-template-group + .ending-template-group) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      align-items: start;
    }
    .ending-template-example-layout {
      grid-template-columns: minmax(220px, .85fr) minmax(0, 1.15fr);
      align-items: start;
    }
    .ending-template-extra .ending-template-examples { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ending-template-more .ending-template-examples { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }

  @container (580px <= width < 680px) {
    .ending-template-feature .ending-template-word { font-size: 20px; }
    .ending-template-example-layout .ending-template-extra .ending-template-word { gap: 4px; font-size: 13px; }
    .ending-template-example-layout .ending-template-extra .ending-template-word strong { font-size: 17px; }
  }
}

.ending-template details {
  padding: 7px 10px;
  border: 1px solid var(--ending-border);
  border-radius: 8px;
  background: #fff;
}
.ending-template details[open] > summary { margin-bottom: 7px; }
.ending-template summary {
  min-height: 28px;
  color: var(--ending-blue);
  font-weight: 700;
  cursor: pointer;
}

.ending-template-help h4 { margin-block-start: 12px; }

.ending-template .ending-template-letters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 100px), 1fr));
  gap: 6px;
  margin-block: 8px;
  padding: 0;
  list-style: none;
}

.ending-template-letters li {
  padding: 6px 8px;
  border: 1px solid var(--ending-border);
  border-radius: 8px;
  background: var(--ending-soft);
  overflow-wrap: anywhere;
}

.ending-template-letters div {
  text-align: left;
}

.ending-template-letters strong {
  display: inline-block;
  min-inline-size: 1.35em;
  border-radius: 4px;
  background: #d8edf5;
  color: var(--ending-blue);
  text-align: center;
}

.ending-template-letters p { color: var(--ending-muted); }
