:root {
  --bg: #fff7fb;
  --card: #ffffff;
  --ink: #32252d;
  --muted: #7e6a75;
  --line: #f0dbe7;
  --accent: #f184b6;
  --accent-dark: #cf5e91;
  --soft: #ffe4f0;
  --soft-2: #fff0d8;
  --shadow: 0 18px 42px rgba(120, 60, 96, 0.18);
  --radius-xl: 28px;
  --radius-md: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 10%, #ffe0ef 0 18%, transparent 19%),
    radial-gradient(circle at 90% 0%, #fff0c7 0 14%, transparent 15%),
    linear-gradient(180deg, var(--bg), #fff);
}

button,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  place-items: center;
}

.hero-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(14px);
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2.1rem;
  line-height: 1;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
}

.character-stage {
  min-height: 210px;
  display: grid;
  place-items: end center;
  margin: 4px 0 14px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 240, 248, 0.95), rgba(255, 252, 247, 0.95)),
    repeating-linear-gradient(45deg, transparent 0 16px, rgba(241, 132, 182, 0.06) 17px 18px);
  overflow: hidden;
  position: relative;
}

.character-stage::before,
.character-stage::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: rgba(241, 132, 182, 0.12);
}

.character-stage::before {
  width: 110px;
  height: 110px;
  left: 24px;
  top: 24px;
}

.character-stage::after {
  width: 160px;
  height: 52px;
  right: -34px;
  bottom: 24px;
}

.ken-avatar {
  width: 156px;
  height: 188px;
  position: relative;
  z-index: 1;
  transform-origin: center bottom;
  animation: floaty 2.8s ease-in-out infinite;
}

.face {
  width: 116px;
  height: 104px;
  position: absolute;
  left: 20px;
  top: 38px;
  background: #ffe0ca;
  border: 4px solid #4b3542;
  border-radius: 48% 48% 52% 52%;
  box-shadow: inset 0 -6px 0 rgba(155, 85, 85, 0.08);
  z-index: 2;
}

.hair {
  position: absolute;
  background: #6b4a58;
  z-index: 3;
}

.hair-left {
  width: 96px;
  height: 66px;
  left: 18px;
  top: 18px;
  border-radius: 62px 44px 28px 36px;
  transform: rotate(-7deg);
}

.hair-right {
  width: 78px;
  height: 72px;
  right: 20px;
  top: 20px;
  border-radius: 40px 62px 34px 28px;
  transform: rotate(10deg);
}

.eye {
  width: 12px;
  height: 18px;
  position: absolute;
  top: 48px;
  background: #3d2a34;
  border-radius: 999px;
}

.eye-left {
  left: 34px;
}

.eye-right {
  right: 34px;
}

.mouth {
  width: 24px;
  height: 12px;
  position: absolute;
  left: 50%;
  top: 74px;
  border-bottom: 4px solid #8d5363;
  border-radius: 0 0 999px 999px;
  transform: translateX(-50%);
}

.cheek {
  width: 18px;
  height: 10px;
  position: absolute;
  top: 68px;
  background: rgba(241, 132, 182, 0.36);
  border-radius: 999px;
}

.cheek-left {
  left: 18px;
}

.cheek-right {
  right: 18px;
}

.body {
  width: 104px;
  height: 82px;
  position: absolute;
  left: 26px;
  bottom: 0;
  background: linear-gradient(180deg, #f184b6, #d9699b);
  border: 4px solid #4b3542;
  border-radius: 42px 42px 26px 26px;
  z-index: 1;
}

.body::before,
.body::after {
  content: "";
  position: absolute;
  top: 18px;
  width: 28px;
  height: 18px;
  background: #ffe0ca;
  border: 4px solid #4b3542;
  border-radius: 999px;
}

.body::before {
  left: -22px;
  transform: rotate(-18deg);
}

.body::after {
  right: -22px;
  transform: rotate(18deg);
}

.ken-avatar.is-smile .mouth {
  width: 30px;
  height: 16px;
  border-bottom-width: 5px;
}

.ken-avatar.is-blush .cheek {
  background: rgba(235, 91, 143, 0.62);
}

.ken-avatar.is-blush {
  animation: shy 1.4s ease-in-out infinite;
}

.ken-avatar.is-surprised .eye {
  height: 20px;
  width: 14px;
}

.ken-avatar.is-surprised .mouth {
  width: 16px;
  height: 16px;
  border: 4px solid #8d5363;
  border-radius: 999px;
}

.ken-avatar.is-sad .mouth {
  top: 80px;
  border-top: 4px solid #8d5363;
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
}

.dialogue-card {
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 18px rgba(110, 60, 90, 0.08);
}

.speaker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.speaker-name {
  font-weight: 800;
  color: var(--accent-dark);
}

.emotion-label {
  color: var(--muted);
  font-size: 0.78rem;
  background: var(--soft);
  border-radius: 999px;
  padding: 3px 8px;
}

.ken-line {
  min-height: 3.8em;
  white-space: pre-line;
  line-height: 1.75;
  font-size: 1.03rem;
}

.mode-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 14px 0;
}

.mode-button,
.send-button {
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  font-weight: 800;
}

.mode-button {
  background: #fff;
  color: var(--accent-dark);
  border: 1px solid var(--line);
}

.mode-button.is-active {
  background: var(--soft);
  border-color: rgba(241, 132, 182, 0.65);
  box-shadow: inset 0 0 0 1px rgba(241, 132, 182, 0.18);
}

.talk-form {
  display: grid;
  gap: 8px;
}

.talk-form label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  color: var(--ink);
  background: #fff;
  outline: none;
  line-height: 1.6;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(241, 132, 182, 0.13);
}

.send-button {
  color: #fff;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  box-shadow: 0 10px 18px rgba(207, 94, 145, 0.22);
}

.status-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
}

.status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.status-header h2 {
  font-size: 1rem;
}

.status-header span {
  color: var(--muted);
  font-size: 0.82rem;
}

.parameter-list {
  display: grid;
  gap: 10px;
}

.parameter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.parameter-label {
  font-weight: 700;
}

.parameter-value {
  color: var(--muted);
}

.meter {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #f6e7ef;
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #ffb765);
  transition: width 220ms ease;
}

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes shy {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-5px) rotate(1deg); }
}

@media (min-width: 460px) {
  .mode-panel {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ken-avatar,
  .ken-avatar.is-blush {
    animation: none;
  }

  .meter-fill {
    transition: none;
  }
}
