:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f3f7ff;
  background: #080f20;
  --ink: #f3f7ff;
  --muted: #aebed7;
  --glow: #bce8ff;
  --line: rgba(175, 207, 255, .19);
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  background:
    radial-gradient(ellipse 36rem 28rem at 86% 5%, #163361 0%, transparent 88%),
    radial-gradient(ellipse 38rem 26rem at 3% 100%, #12294b 0%, transparent 90%),
    linear-gradient(158deg, #0c152b 0%, #080f20 66%);
}

button, input { font: inherit; }
button { color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .56; }
button:focus-visible, input:focus-visible { outline: 2px solid #a2e6ff; outline-offset: 3px; }

.shell {
  width: min(100%, 71rem);
  padding: max(15px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  margin-inline: auto;
}

.topbar, .brand, .result-heading, .sheet-heading { display: flex; align-items: center; }
.topbar { justify-content: space-between; gap: .65rem; margin-bottom: 1.15rem; }
.brand { gap: .65rem; font-weight: 690; font-size: 1.075rem; letter-spacing: -.025em; }
.brand img { border-radius: 13px; border: 1px solid rgba(183, 221, 255, .26); box-shadow: 0 4px 19px rgba(54, 107, 222, .28); }

.glass {
  background: linear-gradient(151deg, rgba(43, 66, 104, .72) 0%, rgba(20, 34, 60, .79) 48%, rgba(14, 24, 45, .91) 100%);
  border: 1px solid var(--line);
  border-top-color: rgba(200, 221, 255, .31);
  border-radius: 25px;
  box-shadow: 0 16px 44px -22px #000c, inset 0 1px 0 rgba(255, 255, 255, .045);
  -webkit-backdrop-filter: blur(22px) saturate(125%);
  backdrop-filter: blur(22px) saturate(125%);
}

.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: center;
  min-height: 13.2rem;
  overflow: hidden;
  background: #071126;
}

.hero-art {
  position: absolute;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: right 50%;
}

.hero::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(0deg, #07112694 0%, transparent 53%),
    linear-gradient(90deg, #071126 1%, rgba(7, 17, 38, .92) 31%, rgba(7, 17, 38, .48) 68%, transparent);
  content: "";
}

.hero-content { padding: 1.45rem 1.32rem 1.55rem; }
.context {
  margin: 0 0 .65rem;
  color: #b0d9f9;
  font-size: .875rem;
  font-weight: 680;
  letter-spacing: .075em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2.35rem, 6.8vw, 4.4rem); font-weight: 760; letter-spacing: -.065em; line-height: .98; }
h1 em { display: inline-block; color: var(--glow); font-style: normal; }
.hero-content > p:last-child { max-width: 25rem; margin-top: .85rem; color: #d3def1; line-height: 1.45; }

.workspace { display: grid; gap: .9rem; margin-top: .9rem; }
.editor, .result { padding: 1.1rem; min-width: 0; }
.editor label, h2 { display: block; font-size: 1.26rem; letter-spacing: -.035em; font-weight: 720; line-height: 1.18; }
.hint { color: var(--muted); font-size: .875rem; line-height: 1.35; margin-top: .4rem; }

.field {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  min-height: 58px;
  margin-top: .95rem;
  padding: 4px;
  border: 1px solid rgba(171, 209, 255, .23);
  border-radius: 16px;
  background: rgba(5, 13, 28, .69);
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, .27);
}

.field:focus-within { border-color: #9cd7ff; box-shadow: 0 0 0 2px #8aceff26, inset 0 4px 12px #0004; }
.field:has(input[aria-invalid="true"]) { border-color: #ec9fa3; }
.field input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 4px 0 10px;
  color: var(--ink);
  font: 690 clamp(1rem, 4.3vw, 1.24rem)/1 var(--mono);
  font-variant-numeric: slashed-zero;
  letter-spacing: .025em;
  background: transparent;
  border: 0;
  outline: 0;
  text-transform: uppercase;
}

.field input::placeholder { opacity: 1; color: #8ba1c2; font-weight: 500; text-transform: none; }
.field input:focus-visible { outline: 0; }

.pill, .paste, .clear, .text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .48rem;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: .875rem;
  font-weight: 680;
  line-height: 1.25;
  touch-action: manipulation;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}

.pill { padding: .48rem .8rem; white-space: nowrap; }
.secondary { background: rgba(169, 204, 255, .092); border-color: rgba(181, 216, 255, .22); }
.primary { color: #0c2340; background: linear-gradient(160deg, #daf3ff 0%, #a0d6ff 93%); border-color: #ddf5ff; box-shadow: 0 6px 16px -6px #78bcff7a, inset 0 1px 0 #fff9; }
.paste { padding: .4rem .55rem; border-radius: 12px; color: #c6e8ff; background: rgba(100, 167, 250, .13); border-color: rgba(137, 197, 255, .13); }
.clear { padding: 0; min-width: 44px; color: #b8cbe5; background: transparent; }
.text-button { padding: 0 6px; margin: .33rem 0 -.45rem -6px; color: #b7e0ff; background: transparent; }
.text-button:active, .clear:active, .secondary:active, .paste:active { background: rgba(182, 215, 255, .19); }
.pill:not(:disabled):active, .paste:active { transform: scale(.97); }

@media (hover: hover) {
  .secondary:not(:disabled):hover, .paste:hover, .clear:hover { background: rgba(182, 215, 255, .19); }
  .primary:not(:disabled):hover { background: #e7f6ff; }
  .text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
}

.error, .feedback { margin: .55rem 0 0; font-size: .875rem; line-height: 1.35; }
.error { color: #ffc3c7; }
.feedback { color: #c4e9ff; }
.result-heading { justify-content: space-between; gap: .45rem; }
.badge { flex-shrink: 0; padding: .37rem .55rem; border-radius: 20px; background: rgba(143, 194, 255, .125); border: 1px solid rgba(175, 212, 255, .16); color: #c5e3fb; font-size: .78rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.words { list-style: none; padding: 0; margin: .95rem 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }

.word {
  display: flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  gap: .46rem;
  padding: .32rem .42rem;
  background: rgba(8, 18, 36, .55);
  border: 1px solid rgba(160, 195, 249, .14);
  border-radius: 12px;
  box-shadow: inset 0 1px rgba(255, 255, 255, .026);
}

.result[data-state="example"] .word { background: rgba(8, 18, 36, .28); }
.character {
  display: grid;
  place-items: center;
  flex: 0 0 1.72rem;
  min-height: 1.72rem;
  border-radius: 7px;
  font: 700 .97rem/1 var(--mono);
  font-variant-numeric: slashed-zero;
  background: #243859;
  color: #e6efff;
}

.word[data-kind="digit"] .character { background: #153f52; color: #99f0ef; }
.word[data-kind="dash"] .character { background: #333c59; color: #e1ddff; }
.codeword { min-width: 0; overflow-wrap: anywhere; font-size: .94rem; font-weight: 610; line-height: 1.15; }
.result .words { margin-bottom: 0; }
.result .words:empty { display: none; }
.actions { display: grid; grid-template-columns: 1.16fr 1fr; gap: .5rem; margin-top: .95rem; }
.actions .pill { min-height: 47px; padding-inline: .38rem; }

footer { display: flex; align-items: center; justify-content: center; gap: .52rem; margin: 1.15rem auto 0; color: var(--muted); font-size: .82rem; line-height: 1.35; }

.glyph { position: relative; display: inline-block; flex: 0 0 1em; width: 1em; height: 1em; }
.glyph::before, .glyph::after { content: ""; position: absolute; }
.book::before { inset: 1px 0 1px; border: 1.4px solid currentColor; border-radius: 3px; }
.book::after { left: 50%; top: 2px; bottom: 2px; border-left: 1.4px solid currentColor; }
.clipboard::before { left: 2px; top: 2px; right: 2px; bottom: 0; border: 1.4px solid currentColor; border-radius: 2px; }
.clipboard::after { left: 4px; top: 0; right: 4px; height: 4px; border: 1.4px solid currentColor; border-radius: 2px; background: #1e314d; }
.copy::before, .copy::after { width: 10px; height: 10px; border: 1.4px solid currentColor; border-radius: 2px; }
.copy::before { top: 0; left: 0; opacity: .68; }
.copy::after { top: 4px; left: 4px; background: #182944; }
.cross::before, .cross::after { left: 1px; right: 1px; top: 50%; height: 1.5px; border-radius: 2px; background: currentColor; transform: rotate(45deg); }
.cross::after { transform: rotate(-45deg); }
.audio::before { left: 0; top: 1px; width: 9px; height: 12px; background: currentColor; clip-path: polygon(0 33%, 40% 33%, 100% 0, 100% 100%, 40% 67%, 0 67%); }
.audio::after { right: 0; top: 1px; width: 8px; height: 12px; border: 1.5px solid transparent; border-right-color: currentColor; border-radius: 50%; }
[data-playing] .audio::before { top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 2px; clip-path: none; }
[data-playing] .audio::after { display: none; }
.lock::before { left: 1px; right: 1px; bottom: 0; height: 8px; border: 1.3px solid currentColor; border-radius: 2px; }
.lock::after { left: 3px; right: 3px; top: 0; height: 6px; border: 1.3px solid currentColor; border-bottom: 0; border-radius: 5px 5px 0 0; }

dialog.glass { width: min(32rem, calc(100% - 2rem)); padding: 0; color: var(--ink); max-height: 85dvh; overflow: auto; overscroll-behavior: contain; background: #15243e; }
dialog::backdrop { background: #030916b3; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.sheet-heading { position: sticky; z-index: 1; top: 0; justify-content: space-between; gap: 1rem; padding: .85rem 1.1rem; background: #192b47; border-bottom: 1px solid var(--line); }
.close { min-width: 44px; }
.sheet-content { padding: 1rem 1.1rem 1.1rem; }
.sheet-content h3 { font-size: 1rem; }
.reference { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: .65rem; }
.reference .word { min-height: 66px; flex-direction: column; justify-content: center; gap: .25rem; text-align: center; }
.reference .character { flex-basis: auto; min-width: 1.72rem; }
.reference .codeword { font-size: .875rem; }
.reference:last-child { margin-bottom: 0; }

@media (max-width: 365px) {
  .editor, .result { padding: .9rem; }
  .pill, .paste { gap: .38rem; }
  .paste { padding-inline: .43rem; }
  .paste .glyph { display: none; }
}

@media (min-width: 42rem) {
  .shell { padding-inline: 2rem; }
  .hero { min-height: 15.25rem; }
  .hero-content { padding-inline: 2.2rem; }
  .hero::after { background: linear-gradient(90deg, #071126 2%, rgba(7, 17, 38, .71) 36%, transparent 78%); }
  .workspace { grid-template-columns: minmax(0, .87fr) minmax(0, 1.13fr); gap: 1.1rem; margin-top: 1.1rem; align-items: start; }
  .editor, .result { padding: 1.35rem; }
}

@media (min-width: 60rem) {
  .shell { padding-top: 1.6rem; }
  .hero { min-height: 17rem; }
  .hero-content { padding-inline: 2.6rem; }
  .workspace { grid-template-columns: minmax(0, .73fr) minmax(0, 1.27fr); }
  .editor, .result { padding: 1.45rem; }
  .result .words { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .actions { display: flex; }
  .actions .pill { min-width: 116px; padding-inline: .9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
