:root {
  color-scheme: light;
  --page: #f4f5fb;
  --white: #fff;
  --ink: #16182d;
  --muted: #535a73;
  --subtle: #656b84;
  --line: #dce0ec;
  --accent: #4936cb;
  --accent-dark: #3826ac;
  --accent-soft: #ede9ff;
  --focus: #5c46e0;
  --display: Georgia, Cambria, "Times New Roman", serif;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-size: 1rem;
  line-height: 1.5;
}

button, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.page-width {
  width: min(100% - 3rem, 69rem);
  margin-inline: auto;
}

.site-header {
  background: #fafaff;
  border-bottom: 1px solid var(--line);
}

.header-inner, .brand, .languages {
  display: flex;
  align-items: center;
}

.header-inner {
  min-height: 4.5rem;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  gap: .65rem;
  font-size: 1.14rem;
  font-weight: 730;
  letter-spacing: -.035em;
}

.brand-mark {
  display: grid;
  width: 2.2rem;
  height: 2.2rem;
  place-items: center;
  border-radius: .65rem;
  background: var(--accent);
  color: var(--white);
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.45rem;
  line-height: 1;
}

.languages {
  gap: .125rem;
  padding: .2rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
}

.languages a {
  display: grid;
  min-width: 2.55rem;
  min-height: 2rem;
  place-items: center;
  border-radius: .48rem;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 650;
  text-decoration: none;
}

.languages a:hover {
  background: #eeeff7;
}

.languages a[aria-current] {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

main {
  padding-block: 3.4rem 2.5rem;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(19rem, 23.75rem);
  align-items: center;
  gap: clamp(1.6rem, 5vw, 4.5rem);
  margin-bottom: 2.25rem;
}

.intro h1 {
  max-width: 15ch;
  margin: 0;
  font: 400 clamp(2.7rem, 5vw, 4.2rem) / 1.015 var(--display);
  letter-spacing: -.05em;
  text-wrap: balance;
}

.intro-text p {
  max-width: 32rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.06rem;
  line-height: 1.55;
}

.letter-board {
  padding: 1.1rem;
  border-radius: 1.12rem;
  background: #211a46;
  color: #fff;
}

.letter-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: .25rem .5rem;
  margin-bottom: .65rem;
}

.letter-heading h2 {
  margin: 0;
  font-size: .94rem;
  font-weight: 660;
}

.letter-heading span {
  color: #d0c8ed;
  font-size: .78rem;
}

.letter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .4rem;
}

.letter {
  overflow: clip;
  min-width: 0;
  border: 1px solid #4c4170;
  border-radius: .6rem;
  background: #302653;
  text-align: center;
}

.glyphs {
  display: flex;
  min-height: 3rem;
  justify-content: center;
}

.glyph {
  flex: 1 1 50%;
  min-width: 0;
  padding: .12rem .1rem;
  border: 0;
  background: transparent;
  color: #fff;
  font: 400 clamp(1.36rem, 2.25vw, 2.1rem) / 1.15 var(--display);
}

.glyph-lower {
  color: #dcd3ff;
  font-size: clamp(1.15rem, 1.9vw, 1.75rem);
}

.glyph:hover {
  background: #4a377a;
  color: #fff;
}

.glyph:focus-visible {
  outline-color: #c6b4ff;
  outline-offset: -3px;
}

.letter p {
  margin: 0;
  padding: .26rem .1rem .35rem;
  border-top: 1px solid #4c4170;
  color: #ddd6f0;
  font-size: .78rem;
  white-space: nowrap;
}

.letter p [aria-hidden] {
  color: #b6a9d6;
}

.converter {
  padding: 1.25rem;
  border: 1px solid #d9dce9;
  border-radius: 1.25rem;
  background: var(--white);
  box-shadow: 0 .65rem 1.75rem rgb(31 25 76 / 6%);
}

.mode-field {
  min-width: 0;
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
}

.mode-options {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  gap: .2rem;
  padding: .24rem;
  border-radius: .78rem;
  background: #eff0f7;
}

.mode-option {
  position: relative;
  display: grid;
  cursor: pointer;
}

.mode-option input, .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.mode-option span {
  display: grid;
  min-height: 2.35rem;
  align-items: center;
  padding: .3rem .9rem;
  border-radius: .55rem;
  color: var(--muted);
  font-weight: 620;
  font-size: .9rem;
  text-align: center;
}

.mode-option:hover span {
  color: var(--accent-dark);
}

.mode-option input:checked + span {
  background: var(--white);
  color: var(--accent-dark);
  box-shadow: 0 1px 3px rgb(31 25 76 / 17%);
}

.mode-option input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: -1px;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas: "source result" "run run";
  gap: 1rem;
}

.editor {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: .85rem;
}

.editor:focus-within {
  border-color: #a99bf1;
}

.source-editor {
  grid-area: source;
}

.result-editor {
  grid-area: result;
  background: #f8f7ff;
  border-color: #e1dcf5;
}

.editor-header {
  display: flex;
  min-height: 3.1rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .15rem .5rem;
  padding: .3rem .8rem .3rem 1rem;
  border-bottom: 1px solid var(--line);
}

.editor-header label {
  font-size: .95rem;
  font-weight: 670;
}

.editor-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
}

.text-button {
  min-height: 2.25rem;
  padding: .25rem .48rem;
  border: 0;
  border-radius: .35rem;
  background: transparent;
  color: var(--accent-dark);
  font-size: .84rem;
  font-weight: 650;
}

.text-button:enabled:hover {
  background: var(--accent-soft);
}

.text-button:disabled {
  color: #6a6f84;
  opacity: .78;
}

.clear-button {
  color: var(--muted);
}

.editor textarea {
  display: block;
  width: 100%;
  height: 12rem;
  min-height: 8rem;
  flex: 1 1 auto;
  padding: .95rem 1rem;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.65;
  resize: vertical;
}

.editor textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.editor textarea::placeholder {
  color: var(--subtle);
  opacity: 1;
}

.editor-count {
  padding: .38rem 1rem;
  border-top: 1px solid var(--line);
  color: var(--subtle);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
}

.run {
  grid-area: run;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .65rem 1rem;
}

.convert-button {
  min-width: 10.5rem;
  min-height: 3rem;
  padding: .55rem 1.25rem;
  border: 1px solid var(--accent);
  border-radius: .68rem;
  background: var(--accent);
  color: var(--white);
  font-weight: 680;
}

.convert-button:enabled:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.convert-button:disabled {
  opacity: .7;
}

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

.tool-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  margin-top: 1rem;
  padding-top: .82rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .83rem;
}

.tool-footer p {
  margin: 0;
}

.shortcut {
  white-space: nowrap;
}

kbd {
  padding: .06rem .25rem;
  border: 1px solid var(--line);
  border-radius: .25rem;
  background: #f7f7fb;
  font-family: inherit;
  font-size: .82rem;
}

.reference {
  margin-top: 1.65rem;
  padding: 0 .1rem;
}

.reference-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .55rem 1rem;
}

.reference h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 675;
}

.reference p {
  margin: .25rem 0 0;
  color: var(--muted);
  font-size: .9rem;
}

.law-link, .rules summary {
  color: var(--accent-dark);
  font-size: .875rem;
  font-weight: 640;
}

.law-link {
  text-underline-offset: .17em;
}

.rules {
  margin-top: .7rem;
}

.rules summary {
  width: fit-content;
  cursor: pointer;
}

.rules p {
  max-width: 54rem;
  margin-top: .5rem;
}

.no-script {
  color: #992f30;
}

@media (max-width: 760px) {
  .page-width {
    width: calc(100% - 2rem);
  }

  main {
    padding-block: 2rem;
  }

  .intro {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.25rem;
  }

  .intro h1 {
    max-width: 19ch;
  }

  .intro-text p {
    margin-top: .7rem;
    font-size: 1rem;
  }

  .letter-board {
    width: min(100%, 24rem);
    padding: .75rem;
  }

  .converter {
    padding: .8rem;
  }

  .editor-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "source" "run" "result";
    gap: .75rem;
  }

  .editor textarea {
    height: 9rem;
  }

  .mode-options {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mode-option span {
    min-height: 2.5rem;
    padding-inline: .25rem;
    font-size: .85rem;
  }

  .shortcut {
    display: none;
  }
}

@media (max-width: 360px) {
  .page-width {
    width: calc(100% - 1.35rem);
  }

  .intro h1 {
    font-size: 2.42rem;
  }

  .letter-grid {
    gap: .25rem;
  }

  .editor-header {
    padding-inline: .65rem;
  }

  .text-button {
    padding-inline: .35rem;
  }
}
