:root {
  color-scheme: dark;
  --page: #000;
  --panel-a: #000;
  --panel-b: #282828;
  --ink: #dedede;
  --number-ink: #5572b7;
  --punctuation-ink: #b84e76;
  --muted: #8e8e8e;
  --quiet: #5f5f5f;
  --line: #a8a8a8;
  --control: #fff;
  --control-text: #0b0b0b;
  --glow: 0 0 52px rgba(255, 255, 255, 0.16), 0 18px 65px rgba(255, 255, 255, 0.08);
  --radius: 8px;
  font-family: sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #f5f5f2;
  --panel-a: #fbfbfa;
  --panel-b: #dfdfdc;
  --ink: #111;
  --number-ink: #365aa5;
  --punctuation-ink: #a33e67;
  --muted: #5b5b57;
  --quiet: #777771;
  --line: #484844;
  --control: #fff;
  --control-text: #090909;
  --glow: 0 0 45px rgba(0, 0, 0, 0.12), 0 18px 65px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
}

body {
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  background: var(--page);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  place-items: center;
  padding: 118px 28px 92px;
}

.composer {
  position: fixed;
  top: 28px;
  left: 50%;
  z-index: 3;
  width: min(600px, calc(100vw - 48px));
  transform: translateX(-50%);
  text-align: center;
}

.composer input {
  width: 100%;
  height: 32px;
  border: 1px solid #7c8b99;
  border-radius: 2px;
  background: var(--control);
  color: var(--control-text);
  box-shadow: 0 0 5px rgba(130, 177, 223, 0.55);
  font-size: 13px;
  line-height: 1;
  text-align: center;
  outline: none;
}

.composer input:focus {
  border-color: #b9d7ff;
  box-shadow: 0 0 0 1px rgba(185, 215, 255, 0.5), 0 0 8px rgba(135, 190, 245, 0.7);
}

.composer-actions {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-top: 6px;
}

.text-button,
.post-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--quiet);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.text-button:hover,
.post-button:hover,
.site-footer a:hover {
  color: var(--ink);
}

.top-controls {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: #ffd22d;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

.icon-button:first-child {
  color: var(--quiet);
  font-size: 16px;
}

.theme-toggle {
  color: #ffd22d;
}

:root[data-theme="light"] .theme-toggle {
  color: #1e1e1e;
}

.hide-extra .composer-actions,
.hide-extra .site-footer,
.hide-text-bar .composer,
.hide-theme .theme-toggle {
  display: none;
}

.type-stage {
  width: var(--stage-width, min(92vw, 260px));
  height: var(--stage-height, 520px);
  max-width: 92vw;
  max-height: min(740px, 74vh);
  margin-top: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: repeat(var(--column-count, 1), minmax(0, 1fr));
  grid-template-rows: repeat(var(--row-count, 1), minmax(0, 1fr));
  overflow: hidden;
  box-shadow: var(--glow);
  background: var(--panel-a);
}

.type-tile {
  position: relative;
  --index-lane: var(--counter-lane, clamp(28px, 16%, 58px));
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) var(--index-lane);
  justify-items: center;
  overflow: hidden;
  background: var(--panel-a);
  container-type: size;
}

.type-tile:nth-child(even) {
  background: var(--panel-b);
}

.type-tile + .type-tile {
  border-left: 1px solid rgba(255, 255, 255, 0.02);
}

:root[data-theme="light"] .type-tile + .type-tile {
  border-left-color: rgba(0, 0, 0, 0.05);
}

.hide-backgrounds .type-stage,
.hide-backgrounds .type-tile,
.hide-backgrounds .type-tile:nth-child(even) {
  background: transparent;
}

.hide-backgrounds .type-tile + .type-tile {
  border-left-color: transparent;
}

.glyph {
  grid-row: 1;
  align-self: center;
  justify-self: center;
  max-width: 100%;
  color: var(--ink);
  font-family: monospace;
  font-size: var(--display-font-size, clamp(9rem, min(78cqh, 160cqw), 44rem));
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: 0;
  white-space: pre;
  user-select: none;
}

.glyph[data-space="true"]::before {
  content: " ";
}

.glyph.is-number {
  color: var(--number-ink);
}

.glyph.is-punctuation {
  color: var(--punctuation-ink);
}

.index {
  grid-row: 2;
  align-self: center;
  color: #9c9c9c;
  font-size: clamp(1.3rem, 2vw, 2rem);
  font-weight: 700;
  line-height: 1;
  text-align: center;
  user-select: none;
}

.hide-numbers .type-tile {
  grid-template-rows: minmax(0, 1fr) 0;
}

.hide-numbers .index {
  display: none;
}

.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  color: var(--quiet);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.about-dialog,
.settings-dialog {
  width: min(380px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  background: var(--panel-b);
  color: var(--ink);
  box-shadow: var(--glow);
}

.about-dialog::backdrop,
.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.about-dialog form,
.settings-dialog form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.about-dialog h2,
.about-dialog p,
.settings-dialog h2,
.settings-dialog label {
  margin: 0;
}

.about-dialog h2,
.settings-dialog h2 {
  font-size: 18px;
}

.about-dialog p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.settings-dialog label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.settings-dialog select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 9px;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
}

.setting-row input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--number-ink);
}

.setting-row span {
  font-size: 14px;
  font-weight: 700;
}

.about-dialog button,
.settings-dialog button {
  justify-self: end;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 12px;
  background: var(--page);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 760px) {
  .app {
    padding: 96px 14px 78px;
  }

  .composer {
    top: 18px;
    width: min(420px, calc(100vw - 30px));
  }

  .top-controls {
    top: 10px;
    right: 10px;
  }

  .type-stage {
    max-width: calc(100vw - 24px);
    max-height: 58vh;
    margin-top: 18px;
  }

  .glyph {
    font-size: clamp(7rem, min(76cqh, 154cqw), 30rem);
  }

  .site-footer {
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 0 18px;
    font-size: 12px;
  }
}

@media (max-width: 460px) {
  .composer-actions {
    gap: 16px;
  }

  .text-button {
    font-size: 12px;
  }

  .glyph {
    font-size: clamp(3.5rem, min(50vh, calc(150vw / var(--char-count))), 15rem);
  }

  .index {
    font-size: 1.1rem;
  }
}
