@property --a {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
@property --tint {
  syntax: "<color>";
  inherits: true;
  initial-value: #7f8cff;
}

:root {
  --bg: #07070c;
  --ink: #ffffff;
  --ink-2: rgba(255, 255, 255, 0.74);
  --ink-3: rgba(255, 255, 255, 0.5);
  --ink-4: rgba(255, 255, 255, 0.28);
  --line: rgba(255, 255, 255, 0.09);
  --glass: rgba(18, 18, 28, 0.62);
  --c-cyan: #34c3ff;
  --c-blue: #4f8bff;
  --c-violet: #9b72ff;
  --c-pink: #f25ca8;
  --c-amber: #ffb86b;
  --chroma: conic-gradient(from var(--a), var(--c-cyan), var(--c-blue), var(--c-violet), var(--c-pink), var(--c-violet), var(--c-cyan));
  --radius: 28px;
  --spin: 7s;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Readex Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 300;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: --tint 1.4s ease;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- background: rotating chroma, tinted by the detected dialect ---------- */
.chroma { position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; }
.wheel {
  position: absolute;
  left: 50%; top: -42vmax;
  width: 120vmax; height: 120vmax;
  margin-left: -60vmax;
  border-radius: 50%;
  background: conic-gradient(var(--c-cyan), var(--c-blue), var(--c-violet), var(--c-pink), var(--c-violet), var(--c-blue), var(--c-cyan));
  filter: blur(110px) saturate(1.2);
  opacity: 0.36;
  animation: rotate 38s linear infinite;
}
.tint {
  position: absolute; inset: 0;
  background:
    radial-gradient(60vmax 40vmax at 50% 108%, color-mix(in srgb, var(--tint) 34%, transparent), transparent 70%),
    radial-gradient(80vmax 60vmax at 50% -10%, transparent 40%, var(--bg) 82%);
}
.grain {
  position: fixed; inset: -50%; z-index: -1; pointer-events: none; opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes rotate { to { transform: rotate(1turn); } }
@keyframes spin { to { --a: 1turn; } }
@keyframes flow { to { background-position: 200% 50%; } }

/* ---------- top bar ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1080px; margin: 0 auto; padding: 22px 24px;
}
.mark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 400; letter-spacing: 0.02em; }
.orb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--chroma);
  animation: spin 9s linear infinite;
  box-shadow: 0 0 18px rgba(155, 114, 255, 0.55);
}
.top-right { display: flex; align-items: center; gap: 14px; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--ink-3); }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); }
.status[data-state="ready"] .dot { background: #5ee2a0; box-shadow: 0 0 10px #5ee2a0; }
.status[data-state="waking"] .dot { background: var(--c-amber); animation: pulse 1.2s ease-in-out infinite; }
.status[data-state="offline"] .dot { background: #ff6b6b; }
@keyframes pulse { 50% { opacity: 0.25; } }
.lang { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, 0.03); }
.lang button {
  border: 0; background: none; padding: 5px 12px; border-radius: 999px;
  font-size: 0.78rem; letter-spacing: 0.06em; color: var(--ink-3); transition: color 0.2s, background 0.2s;
}
.lang button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.1); color: var(--ink); }

/* ---------- layout ---------- */
main { max-width: 760px; margin: 0 auto; padding: 0 20px 40px; }
.hero { text-align: center; padding: 6vh 0 34px; }
.eyebrow {
  display: inline-block; margin: 0 0 18px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2);
  background: rgba(255, 255, 255, 0.03);
}
h1 { margin: 0; font-weight: 200; line-height: 1.1; }
h1 .ar {
  display: inline-block;
  font-size: clamp(5rem, 17vw, 9.5rem);
  padding: 0 0.08em 0.06em;
  background: linear-gradient(90deg, #fff 0%, var(--c-cyan) 22%, var(--c-violet) 48%, var(--c-pink) 72%, #fff 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: flow 9s linear infinite;
  filter: drop-shadow(0 8px 40px rgba(155, 114, 255, 0.25));
}
.lede { max-width: 34em; margin: 14px auto 0; font-size: clamp(1.02rem, 2.4vw, 1.18rem); color: var(--ink-2); }

/* ---------- composer with rotating chroma border ---------- */
.composer {
  position: relative; isolation: isolate;
  padding: 22px 22px 14px;
  border-radius: var(--radius);
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px);
}
.composer::before, .composer::after {
  content: ""; position: absolute; border-radius: inherit; pointer-events: none;
  background: var(--chroma);
  animation: spin var(--spin) linear infinite;
}
.composer::before {
  inset: 0; padding: 1px;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0.75;
}
.composer::after { inset: 6px; z-index: -1; filter: blur(28px); opacity: 0.16; transition: opacity 0.5s; }
.composer:focus-within::after { opacity: 0.34; }
.composer.busy { --spin: 1.6s; }
.composer.busy::after { opacity: 0.5; }
textarea {
  display: block; width: 100%; min-height: 3.6em; max-height: 40vh;
  border: 0; outline: 0; resize: none; background: transparent; color: var(--ink);
  font: inherit; font-size: clamp(1.25rem, 3.4vw, 1.6rem); font-weight: 300; line-height: 1.75;
  caret-color: var(--c-violet);
}
textarea::placeholder { color: var(--ink-4); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.count { font-size: 0.8rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 8px; }
.actions button { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; }
.actions svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ghost { background: transparent; color: var(--ink-3); transition: color 0.2s, background 0.2s; }
.ghost:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.go { position: relative; background: #fff; color: #07070c; transition: transform 0.2s; }
.go:hover { transform: scale(1.06); }
.go:active { transform: scale(0.96); }

/* ---------- examples ---------- */
.examples { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; margin: 20px 0 8px; }
.examples-label { font-size: 0.82rem; color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.035);
  font-size: 0.86rem; color: var(--ink-2);
  transition: border-color 0.25s, color 0.25s, background 0.25s, transform 0.2s;
}
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--hue); box-shadow: 0 0 10px var(--hue); }
.chip:hover { color: var(--ink); border-color: color-mix(in srgb, var(--hue) 60%, transparent); background: color-mix(in srgb, var(--hue) 10%, transparent); transform: translateY(-1px); }

/* ---------- result ---------- */
.result {
  margin-top: 26px; padding: 26px 26px 22px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px);
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.kicker { margin: 0 0 4px; font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.verdict { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.label {
  margin: 0; font-size: clamp(2.1rem, 6.4vw, 3.2rem); font-weight: 300; line-height: 1.15;
  background: linear-gradient(90deg, #fff 10%, color-mix(in srgb, var(--tint) 85%, #fff));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.ring { position: relative; flex: none; width: 82px; height: 82px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring-track { stroke: rgba(255, 255, 255, 0.08); }
.ring-fill {
  stroke: var(--tint); stroke-linecap: round;
  stroke-dasharray: 169.65; stroke-dashoffset: 169.65;
  filter: drop-shadow(0 0 6px var(--tint));
  transition: stroke-dashoffset 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ring-value { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.05rem; font-weight: 400; font-variant-numeric: tabular-nums; }

.bars { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 11px; }
.bars li { display: grid; grid-template-columns: 8.5em 1fr 3.2em; align-items: center; gap: 14px; font-size: 0.92rem; color: var(--ink-3); }
.bars li.win { color: var(--ink); }
.track { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.fill {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--hue) 55%, transparent), var(--hue));
  box-shadow: 0 0 12px color-mix(in srgb, var(--hue) 60%, transparent);
  transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.pct { text-align: end; font-variant-numeric: tabular-nums; }

.weighed { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.words { margin: 6px 0 0; font-size: 1.32rem; line-height: 2.1; color: var(--ink-3); }
.words mark {
  color: var(--ink); padding: 0.05em 0.28em; border-radius: 8px;
  background: color-mix(in srgb, var(--tint) calc(var(--w) * 55%), transparent);
  box-shadow: 0 0 calc(var(--w) * 22px) color-mix(in srgb, var(--tint) calc(var(--w) * 45%), transparent);
}
.hint { margin: 8px 0 0; font-size: 0.84rem; color: var(--ink-3); }

.pending { display: grid; gap: 12px; }
.shimmer {
  height: 14px; border-radius: 999px;
  background: linear-gradient(90deg, rgba(79, 139, 255, 0.15), rgba(155, 114, 255, 0.55), rgba(242, 92, 168, 0.2), rgba(79, 139, 255, 0.15));
  background-size: 200% 100%; animation: flow 1.6s linear infinite;
}
.shimmer.short { width: 62%; }
.progress { height: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); overflow: hidden; margin-top: 4px; }
.progress span {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--c-cyan), var(--c-violet), var(--c-pink));
  box-shadow: 0 0 14px rgba(155, 114, 255, 0.7);
  transition: width 0.3s ease;
}
.status[data-state="loading"] .dot { background: var(--c-violet); animation: pulse 1.2s ease-in-out infinite; }
.note { margin: 16px 4px 0; text-align: center; font-size: 0.9rem; color: var(--ink-2); }

/* ---------- stats & about ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 56px; }
.stat {
  display: flex; flex-direction: column; gap: 4px; padding: 18px 18px 16px;
  border: 1px solid var(--line); border-radius: 20px; background: rgba(255, 255, 255, 0.025);
}
.stat-value {
  font-size: 1.7rem; font-weight: 300; font-variant-numeric: tabular-nums;
  background: linear-gradient(90deg, #fff, #d9ccff); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-label { font-size: 0.8rem; color: var(--ink-3); line-height: 1.4; }
.about { margin: 26px 4px 0; font-size: 0.92rem; color: var(--ink-2); }
.about p { margin: 0 0 10px; }
.about .limits { color: var(--ink-3); }

.foot {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 26px;
  max-width: 760px; margin: 0 auto; padding: 26px 20px calc(34px + env(safe-area-inset-bottom));
  font-size: 0.86rem; color: var(--ink-3);
}
.foot a { text-decoration: none; transition: color 0.2s; }
.foot a:hover { color: var(--ink); }
.foot .me {
  background: linear-gradient(90deg, var(--c-cyan), var(--c-violet), var(--c-pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

:focus-visible { outline: 2px solid color-mix(in srgb, var(--c-violet) 80%, #fff); outline-offset: 3px; border-radius: 10px; }

@media (max-width: 640px) {
  .top { padding: 16px 16px; }
  .status #status-text { display: none; }
  main { padding: 0 16px 32px; }
  .hero { padding: 3vh 0 26px; }
  .composer { padding: 18px 18px 12px; }
  .result { padding: 22px 18px 18px; }
  .bars li { grid-template-columns: 6.6em 1fr 2.9em; gap: 10px; font-size: 0.86rem; }
  .stats { grid-template-columns: 1fr; gap: 10px; margin-top: 40px; }
  .stat { padding: 16px 18px 14px; }
  .stat-value { font-size: 1.5rem; }
  .ring { width: 70px; height: 70px; }
}

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