@font-face {
  font-family: "Noto Sans Egyptian Hieroglyphs";
  src: url("/_a/noto-egyptian-sub.cd178a6264.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+13000-1342F;
}

:root {
  --glyph-font: "Noto Sans Egyptian Hieroglyphs";
}

.tool-shell {
  min-width: 0;
  padding: var(--space-3);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-card);
  background: var(--sheet);
  box-shadow: var(--shadow-sheet);
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
}

.tool-label,
.tool-alphabet {
  display: block;
  margin: 0 0 var(--space-1);
  font-weight: 600;
}

.tool-entry [data-input],
.tool-alphabet select,
.tool-share-box {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  border: var(--stroke-input);
  border-radius: var(--radius-ctrl);
  color: var(--ink);
  background: var(--input-face);
  font: 400 var(--text-body) / var(--leading-body) var(--font-body);
}

.tool-entry textarea,
.tool-share-box {
  min-height: 64px;
  padding: var(--space-3);
  resize: vertical;
}

.tool-entry [aria-invalid="true"] {
  border-color: var(--ochre);
}

.tool-count,
.tool-note,
.tool-error,
.tool-status {
  margin: var(--space-1) 0 0;
}

.tool-count,
.tool-result-type,
.tool-extra {
  color: var(--muted);
  font-size: var(--text-meta);
  line-height: 18px;
}

.tool-count {
  font-variant-numeric: tabular-nums;
}

.tool-error {
  color: var(--ochre);
}

.tool-options,
.tool-examples,
.tool-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
}

.tool-options {
  min-width: 0;
  gap: 0 var(--space-3);
  padding: 0;
  border: 0;
}

.tool-options label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  cursor: pointer;
}

.tool-options input {
  appearance: none;
  display: grid;
  flex: none;
  place-items: center;
  width: 20px;
  height: 20px;
  margin: 0;
  border: var(--stroke-input);
  border-radius: 4px;
  background: var(--input-face);
  cursor: inherit;
}

.tool-options input:checked {
  border-color: var(--lapis-600);
  background: var(--lapis-600);
}

.tool-options input:checked::after {
  width: 10px;
  height: 6px;
  border-bottom: 2px solid white;
  border-left: 2px solid white;
  transform: translateY(-1px) rotate(-45deg);
  content: "";
}

.tool-options .glyph {
  font-size: var(--text-title);
}

.tool-alphabet {
  margin: var(--space-2) 0 0;
}

.tool-alphabet select {
  margin-top: var(--space-1);
}

.tool-result-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0 var(--space-2);
  margin-bottom: var(--space-1);
}

.tool-result-heading p {
  margin: 0;
}

.tool-display,
.tool-empty {
  min-height: 6.5rem;
  padding: var(--space-2);
  border: var(--stroke-gold);
  border-radius: var(--radius-ctrl);
  background: var(--sheet);
}

.tool-display {
  display: grid;
  place-items: center;
  container-type: inline-size;
}

.tool-display:has(.is-cartouche) {
  padding-inline: var(--space-3);
  border-color: transparent;
}

.tool-frame {
  max-width: 100%;
  min-width: 0;
}

.tool-result,
.tool-original {
  margin: 0;
  color: var(--ink);
  text-align: center;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tool-frame.is-cartouche {
  position: relative;
  padding: var(--space-2) var(--space-4);
  border: var(--stroke-gold);
  border-radius: calc(.6 * var(--text-glyph) + 10px);
}

.is-cartouche::before,
.is-cartouche::after {
  position: absolute;
  top: 50%;
  background: var(--gold-line);
  transform: translateY(-50%);
  pointer-events: none;
  content: "";
}

.is-cartouche::before {
  right: -10px;
  width: 10px;
  height: 2px;
}

/* Closing tie bar: outside the oval's right edge, centred, like share.png. */
.is-cartouche::after {
  right: -12px;
  width: 2px;
  height: 55%;
}

/* Cartouche names of 10 signs or fewer stay on one line; the glyph size
   shrinks with the result box (100cqi) down to 24px. */
.tool-frame.is-cartouche.is-fit .tool-result {
  white-space: nowrap;
  overflow-wrap: normal;
  font-size: max(24px, min(var(--text-glyph), calc((100cqi - 64px) / var(--n, 10))));
}

/* Narrow screens: keep signs at 32px or larger and let the cartouche grow to
   two balanced, centred lines instead of shrinking further. Viewport-based:
   the result box is only about 447px wide at 1440, so a container query
   under 480px would also catch desktop. */
@media (max-width: 479.98px) {
  .tool-frame.is-cartouche.is-fit .tool-result {
    white-space: normal;
    word-break: break-all;
    text-wrap: balance;
    font-size: max(32px, min(var(--text-glyph), calc((100cqi - 64px) / var(--n, 10))));
  }
}

.tool-original {
  margin-top: var(--space-1);
}

.tool-empty {
  padding: var(--space-3);
}

.tool-empty p {
  margin: 0;
  font-weight: 600;
}

.disclaimer {
  display: grid;
  max-width: 65ch;
  min-height: 3lh;
  line-height: var(--leading-body);
}

/* The hidden alternate reserves space if one mode needs another line. */
[data-sound-note] > span,
[data-sound-note][data-alternate-note]::after {
  grid-area: 1 / 1;
}

[data-sound-note][data-alternate-note]::after {
  content: attr(data-alternate-note);
  visibility: hidden;
}

.tool-shell button {
  min-width: var(--tap);
  min-height: var(--tap);
  padding: var(--space-1) var(--space-4);
  border: 1.5px solid var(--lapis-600);
  border-radius: var(--radius-ctrl);
  color: var(--lapis-600);
  background: var(--sheet);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.tool-shell button:not(:disabled):hover {
  background: var(--lapis-100);
}

.tool-shell button:not(:disabled):active {
  background: var(--lapis-200);
  transform: scale(.98);
}

.tool-shell .tool-copy {
  min-width: 78px;
  color: white;
  background: var(--lapis-600);
}

.tool-shell .tool-copy:not(:disabled):hover {
  background: var(--lapis-700);
}

.tool-shell .tool-copy:not(:disabled):active {
  background: var(--lapis-800);
}

.tool-shell button:disabled {
  opacity: .4;
  cursor: default;
}

@media (max-width: 360px) {
  .tool-actions > [data-copy] {
    flex: 1 0 100%;
  }

  .tool-actions > :is([data-download], [data-share]) {
    flex: 1;
    white-space: nowrap;
  }
}

.tool-examples button {
  padding-inline: var(--space-3);
  border: 1px solid var(--line);
}

.tool-status:empty {
  margin: 0;
}

.tool-share-box {
  margin-top: var(--space-2);
}

.tool-extra {
  margin-top: var(--space-2);
}

.tool-breakdown {
  margin-top: var(--space-3);
  border-top: 1px solid var(--gold-line);
}

.tool-breakdown summary {
  min-height: var(--tap);
  padding-block: var(--space-2);
  font-weight: 600;
  cursor: pointer;
}

.tool-breakdown ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr));
  gap: var(--space-2);
  padding: 0;
  margin: var(--space-1) 0 0;
  list-style: none;
}

.tool-breakdown li {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto 1fr;
  align-items: center;
  gap: 0 var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-ctrl);
  overflow-wrap: anywhere;
}

.tool-step-source {
  font-weight: 600;
}

.tool-sign {
  font-size: var(--text-sign);
  line-height: 1.2;
}

.tool-step-label,
.tool-step-number {
  grid-column: 1 / -1;
}

.tool-step-number {
  align-self: end;
  color: var(--muted);
  font-size: var(--text-meta);
  line-height: 18px;
}

@media (min-width: 44rem) {
  .tool-shell {
    padding: var(--space-5);
  }

  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-5);
  }

  .disclaimer {
    min-height: 2lh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tool-shell button {
    transition: none;
  }

  .tool-shell button:not(:disabled):active {
    transform: none;
  }
}

@media (forced-colors: active) {
  .tool-options input {
    appearance: auto;
  }

  .tool-options input:checked::after {
    content: none;
  }

  .is-cartouche::before,
  .is-cartouche::after {
    background: CanvasText;
    forced-color-adjust: none;
  }
}
