:root {
  font-family: ui-rounded, "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  color: #283044;
  background: #fff8dc;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 10% 10%, rgba(255,255,255,.95) 0 8%, transparent 9%),
    radial-gradient(circle at 92% 28%, rgba(255,255,255,.7) 0 7%, transparent 8%),
    linear-gradient(180deg, #fff3b2 0%, #e8f9ff 58%, #f7fbff 100%);
}

button { font: inherit; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow { margin: 0 0 2px; font-size: 11px; font-weight: 900; letter-spacing: .14em; color: #e17a38; }
h1 { margin: 0; font-size: clamp(20px, 5vw, 27px); line-height: 1.05; }

.small-button, .icon-button, .replay-me {
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.86);
  box-shadow: 0 4px 14px rgba(62,78,101,.12);
  color: #39455d;
  font-weight: 800;
  cursor: pointer;
}
.small-button { padding: 10px 12px; white-space: nowrap; }
.small-button[aria-pressed="true"] { background: #fff; outline: 3px solid #ffd95c; }

.stage { position: relative; display: grid; place-items: center; min-height: 260px; padding-top: 8px; }
.character { width: min(57vw, 235px); aspect-ratio: 1; filter: drop-shadow(0 14px 14px rgba(71,93,120,.18)); transition: transform .18s ease; }
.character img { width: 100%; height: 100%; display: block; }
.character.listening { animation: bounce .7s ease-in-out infinite alternate; }
.character.speaking { animation: nod .45s ease-in-out infinite alternate; }
.sparkles { position: absolute; top: 42px; font-size: 25px; letter-spacing: 20px; color: #f4aa32; opacity: .85; animation: twinkle 1.6s ease-in-out infinite alternate; }
.name-chip { margin-top: -14px; padding: 7px 14px; border-radius: 999px; background: #fff; font-weight: 900; box-shadow: 0 5px 14px rgba(62,78,101,.12); }

.speech-card {
  position: relative;
  margin-top: 8px;
  padding: 19px 18px 15px;
  border: 3px solid #fff;
  border-radius: 26px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 12px 30px rgba(66,89,119,.13);
}
.speaker-label { font-size: 10px; font-weight: 1000; letter-spacing: .14em; color: #ea7e3c; }
.ai-text { margin: 8px 0 6px; font-size: clamp(23px, 6vw, 31px); line-height: 1.22; font-weight: 900; color: #253354; }
.translation { margin: 8px 0 0; padding-top: 9px; border-top: 1px dashed #cdd8e5; line-height: 1.55; color: #667087; }
.correction { margin: 10px 0 0; padding: 9px 11px; border-radius: 14px; background: #fff7d6; font-size: 14px; }
.hint { margin: 10px 0 0; padding: 10px 12px; border-radius: 14px; background: #e9f7ff; color: #334c68; font-size: 14px; line-height: 1.45; }
.hint strong { color: #1f4d7a; font-size: 16px; }
.reply-actions { display: flex; gap: 8px; align-items: center; min-height: 36px; margin-top: 10px; }
.icon-button { padding: 8px 12px; }
.praise { padding: 7px 11px; border-radius: 999px; background: #dcf9de; color: #237044; font-weight: 1000; animation: pop .3s ease-out; }

.controls { display: grid; justify-items: center; padding: 18px 4px 6px; }
.status { min-height: 22px; margin: 0 0 10px; text-align: center; font-size: 14px; font-weight: 800; color: #63718a; }
.talk-button {
  width: 132px;
  height: 132px;
  display: grid;
  place-content: center;
  gap: 2px;
  border: 7px solid rgba(255,255,255,.82);
  border-radius: 50%;
  background: linear-gradient(145deg, #ffb640, #ff7e55);
  box-shadow: 0 12px 0 #dc603b, 0 20px 30px rgba(205,91,55,.25);
  color: #fff;
  font-weight: 1000;
  font-size: 22px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}
.talk-button:active { transform: translateY(5px); box-shadow: 0 7px 0 #dc603b, 0 12px 18px rgba(205,91,55,.22); }
.talk-button.recording { background: linear-gradient(145deg, #ff6b7b, #e93f62); box-shadow: 0 12px 0 #b72a4b, 0 20px 30px rgba(183,42,75,.25); animation: pulse 1s ease-in-out infinite alternate; }
.talk-button.busy { opacity: .65; cursor: wait; }
.mic { font-size: 35px; line-height: 1; }
.replay-me { margin-top: 20px; padding: 11px 17px; }
button:disabled { opacity: .4; cursor: default; }
.heard { margin: 13px 0 0; padding: 10px 13px; border-radius: 14px; background: rgba(255,255,255,.66); font-size: 14px; }

.history-panel { margin-top: 12px; border-radius: 18px; background: rgba(255,255,255,.66); overflow: hidden; }
.history-panel summary { padding: 13px 15px; font-weight: 900; cursor: pointer; }
.history-list { display: grid; gap: 8px; padding: 0 12px 12px; }
.history-item { padding: 9px 11px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.history-item.assistant { margin-right: 38px; background: #fff; }
.history-item.user { margin-left: 38px; background: #dcf2ff; }
.history-role { display: block; margin-bottom: 2px; font-size: 10px; font-weight: 1000; color: #77849a; }
.setup-notice { margin: 12px 0; padding: 12px 14px; border-radius: 14px; background: #fff2c4; border: 1px solid #f1cf54; font-size: 13px; line-height: 1.5; }

@keyframes bounce { to { transform: translateY(-8px) rotate(1deg); } }
@keyframes nod { to { transform: rotate(-2deg) scale(1.015); } }
@keyframes twinkle { to { opacity: .3; transform: scale(.95); } }
@keyframes pulse { to { transform: scale(1.04); } }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }

@media (max-height: 740px) {
  .stage { min-height: 205px; }
  .character { width: min(44vw, 185px); }
  .talk-button { width: 108px; height: 108px; font-size: 19px; }
  .mic { font-size: 29px; }
  .ai-text { font-size: 22px; }
}
