:root {
  --bg-top: #fcf7f1;
  --bg-bottom: #f3ece2;
  --text: #1f1d1b;
  --muted: #7f7467;
  --panel: rgba(255, 252, 248, 0.62);
  --line: rgba(71, 56, 42, 0.08);
  --arrow-bg: rgba(255, 255, 255, 0.72);
  --arrow-shadow: 0 18px 44px rgba(86, 61, 39, 0.14);
  --word-shadow: 0 22px 50px rgba(107, 79, 52, 0.1);
  --chunk-1: #d46d4b;
  --chunk-2: #2f7c91;
  --chunk-3: #8862d8;
  --chunk-4: #2d9a67;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.92), transparent 28%),
    linear-gradient(160deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

.page-shell {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
}

.ambient {
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(10px);
  opacity: 0.72;
}

.ambient-left {
  top: -110px;
  left: -140px;
  background: radial-gradient(circle, rgba(212, 109, 75, 0.24), transparent 70%);
}

.ambient-right {
  right: -130px;
  bottom: -150px;
  background: radial-gradient(circle, rgba(47, 124, 145, 0.18), transparent 70%);
}

.stage {
  position: relative;
  width: min(1100px, calc(100vw - 180px));
  min-height: min(76vh, 760px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px 160px;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 40px;
  background: var(--panel);
  box-shadow: var(--word-shadow);
  backdrop-filter: blur(22px);
}

.stage::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid var(--line);
  border-radius: 28px;
  pointer-events: none;
}

.word-stage {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  text-align: center;
}

.phonetic {
  margin: 0 0 18px;
  font-family: "Manrope", "Segoe UI Symbol", sans-serif;
  font-size: clamp(1.02rem, 1.85vw, 1.3rem);
  line-height: 1.3;
  letter-spacing: var(--phonetic-track, 0.04em);
  font-weight: 600;
  color: var(--muted);
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "kern" 1;
}

.word-mark {
  margin: 0;
  display: block;
  width: 100%;
  font-family: "Manrope", "Segoe UI", sans-serif;
  font-size: clamp(4.5rem, 11vw, 9.5rem);
  line-height: 0.92;
  letter-spacing: var(--word-track, -0.02em);
  font-weight: 800;
  text-wrap: balance;
  cursor: pointer;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "kern" 1;
  text-rendering: geometricPrecision;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  outline: none;
}

.word-chunk {
  display: inline-block;
  padding: 0;
  vertical-align: baseline;
}

.word-chunk + .word-chunk {
  margin-inline-start: var(--chunk-seam, -0.042em);
}

.word-chunk-1 {
  color: var(--chunk-1);
}

.word-chunk-2 {
  color: var(--chunk-2);
}

.word-chunk-3 {
  color: var(--chunk-3);
}

.word-chunk-4 {
  color: var(--chunk-4);
}

.meaning {
  margin: 22px 0 0;
  font-size: clamp(1.3rem, 2.5vw, 2.05rem);
  font-family: "Noto Serif SC", serif;
  color: rgba(31, 29, 27, 0.86);
}

.edge-arrow {
  border: 0;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, opacity 180ms ease;
}

.edge-arrow:hover,
.edge-arrow:focus-visible {
  transform: translateY(-2px);
}

.bubble-lane {
  position: absolute;
  inset: 18px;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.memory-bubble {
  position: absolute;
  left: 0;
  bottom: 0;
  padding: 0;
  font-family: "Nunito", "Avenir Next Rounded", "Arial Rounded MT Bold", sans-serif;
  font-size: 3rem;
  font-weight: 800;
  line-height: 0.95;
  white-space: nowrap;
  letter-spacing: -0.015em;
  transform: translate3d(0, 0, 0) scale(0.94);
  transform-origin: center bottom;
  opacity: 0;
  filter: saturate(1.03);
  pointer-events: none;
  user-select: none;
  text-rendering: geometricPrecision;
  will-change: transform, opacity;
  backface-visibility: hidden;
}

.memory-bubble-word {
  display: inline-flex;
  align-items: flex-end;
  gap: 0;
  white-space: pre;
}

.memory-bubble-letter {
  display: inline-block;
  min-width: 0.22em;
  transform-origin: 50% 68%;
  will-change: transform, opacity;
}

.memory-bubble-letter-space {
  min-width: 0.3em;
}

.memory-bubble-success {
  color: rgba(103, 176, 120, 0.82);
  text-shadow: 0 10px 18px rgba(120, 200, 139, 0.1);
}

.memory-bubble-error {
  color: rgba(222, 133, 140, 0.78);
  text-shadow: 0 10px 18px rgba(228, 151, 157, 0.1);
}

.memory-dock {
  position: absolute;
  left: 50%;
  bottom: 28px;
  z-index: 3;
  width: min(240px, calc(100% - 56px));
  transform: translateX(-50%);
}

.memory-shell {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 10px 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 18px 38px rgba(71, 56, 42, 0.1);
  backdrop-filter: blur(18px);
}

.memory-shell:focus-within {
  border-color: rgba(212, 109, 75, 0.36);
  box-shadow: 0 18px 38px rgba(71, 56, 42, 0.1), 0 0 0 6px rgba(212, 109, 75, 0.08);
}

.memory-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
}

.memory-input::placeholder {
  color: rgba(127, 116, 103, 0.88);
}

.memory-send {
  flex: none;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(212, 109, 75, 0.92) 0%, rgba(150, 98, 229, 0.82) 100%);
  color: #fff;
  box-shadow: 0 12px 28px rgba(110, 76, 167, 0.18);
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.memory-send:hover,
.memory-send:focus-visible {
  transform: translateY(-2px);
}

.memory-send-icon {
  display: inline-block;
  position: relative;
  top: -1px;
  font-size: 1.1rem;
  font-weight: 700;
}

.edge-arrow {
  position: fixed;
  top: 50%;
  z-index: 3;
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  margin-top: -39px;
  border-radius: 999px;
  background: var(--arrow-bg);
  box-shadow: var(--arrow-shadow);
  color: rgba(31, 29, 27, 0.8);
  font-size: 3rem;
  line-height: 1;
  backdrop-filter: blur(18px);
}

.word-mark:focus-visible {
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.12em;
}

.platform-windows .ambient {
  display: none;
}

.platform-windows body,
.platform-windows .word-mark,
.platform-windows .memory-bubble {
  text-rendering: auto;
}

.platform-windows .stage {
  backface-visibility: hidden;
  transform: translateZ(0);
  contain: layout paint;
}

.platform-windows .stage {
  background: rgba(255, 251, 246, 0.96);
  box-shadow: 0 10px 28px rgba(86, 61, 39, 0.08);
  backdrop-filter: none;
}

.platform-windows .stage::before {
  display: none;
}

.platform-windows .memory-shell,
.platform-windows .edge-arrow {
  backface-visibility: hidden;
  transform: translateZ(0);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 22px rgba(86, 61, 39, 0.08);
  backdrop-filter: none;
}

.performance-lite .memory-bubble {
  filter: none;
}

.performance-lite .memory-bubble-success,
.performance-lite .memory-bubble-error {
  text-shadow: none;
}

.performance-lite .memory-bubble-letter {
  will-change: auto;
}

.platform-windows .stage.pulse .word-stage {
  animation: wordPulseLite 240ms ease-out;
}

.edge-arrow-left {
  left: 24px;
}

.edge-arrow-right {
  right: 24px;
}

.stage.pulse .word-stage {
  animation: wordPulse 420ms ease;
}

@keyframes wordPulse {
  0% {
    transform: translateY(10px);
    opacity: 0.72;
  }

  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes wordPulseLite {
  0% {
    transform: translateY(4px);
    opacity: 0.9;
  }

  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .stage {
    width: min(100%, calc(100vw - 32px));
    min-height: 70vh;
    padding-bottom: 150px;
    border-radius: 32px;
  }

  .edge-arrow {
    width: 64px;
    height: 64px;
    margin-top: -32px;
    font-size: 2.4rem;
  }

  .edge-arrow-left {
    left: 14px;
  }

  .edge-arrow-right {
    right: 14px;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 12px;
  }

  .stage {
    width: 100%;
    min-height: calc(100dvh - 24px);
    padding: 24px 18px 32px;
    border-radius: 28px;
  }

  .stage::before {
    inset: 10px;
    border-radius: 22px;
  }

  .bubble-lane {
    inset: 10px;
  }

  .word-mark {
    font-size: clamp(3.25rem, 16vw, 5.8rem);
    line-height: 0.96;
  }

  .meaning {
    margin-top: 16px;
  }

  .edge-arrow {
    top: auto;
    bottom: 18px;
    margin-top: 0;
    width: 56px;
    height: 56px;
    font-size: 2rem;
  }

  .memory-dock {
    bottom: 86px;
    width: min(220px, calc(100% - 28px));
  }

  .memory-shell {
    padding: 8px 8px 8px 15px;
  }

  .memory-send {
    width: 42px;
    height: 42px;
  }
}
