:root {
  --bg: #f5fbf5;
  --ink: #244234;
  --muted: #49695a;
  --green: #369456;
  --green-dark: #315b47;
  --green-hover: #2e824b;
  --line: #d7e6db;
  --white: #ffffff;
  --shadow: 0 8px 24px rgba(28, 46, 36, 0.08);
  --radius: 4px;
  --max: 375px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #edf4ee;
  color: var(--ink);
  line-height: 1.7;
}

button,
a {
  font-family: inherit;
}

.app {
  min-height: 100dvh;
  max-width: var(--max);
  margin: 0 auto;
  background: var(--bg);
}

.chat-log {
  display: none;
}

.chat-shell-header {
  display: none;
}

.app.chat-mode {
  max-width: 400px;
  background: #f2f8f3;
  box-shadow: 0 20px 60px rgba(36, 66, 52, 0.16);
}

.app.chat-mode .chat-shell-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: block;
  background: var(--white);
}

.chat-shell-title {
  padding: 13px 18px 11px;
  border-bottom: 1px solid #b9d4c2;
  background: #f7fbf8;
  color: var(--green);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
}

.chat-shell-progress {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 18px;
  padding: 9px 20px 11px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.chat-shell-progress__label {
  text-align: center;
  letter-spacing: 0.1em;
}

.chat-shell-progress__track {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe9df;
}

.chat-shell-progress__track div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 0.25s ease;
}

.app.chat-mode .chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 9px 18px;
  background: #f2f8f3;
}

.app.chat-mode .chat-log:empty {
  display: none;
}

#questionPanel {
  width: 100%;
}

.site-footer {
  display: none;
  padding: 14px 10px 12px;
  color: var(--muted);
  font-size: 6px;
  line-height: 1.6;
  text-align: center;
}

.app.opening-mode .site-footer,
.app.result-mode .site-footer {
  display: block;
}

.site-footer__logo {
  display: none;
  width: 140px;
  max-width: 45%;
  height: auto;
  margin: 0 auto 12px;
}

.app.opening-mode .site-footer__logo {
  display: block;
  animation: screen-in 1s ease both;
}

.app.opening-is-leaving .site-footer__logo {
  animation: screen-out 1s ease both !important;
}

.site-footer__links {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 10px;
}

.app.result-mode .site-footer__links {
  display: flex;
}

.site-footer a {
  color: inherit;
  font-size: 9px;
  text-decoration: underline;
}

.site-footer p {
  display: none;
  margin: 5px 0 0;
  font-size: 8px;
}

.app.result-mode .site-footer p {
  display: block;
}

.screen {
  width: 100%;
  min-height: 100dvh;
  animation: screen-in 1s ease both;
}

.app.opening-mode .screen,
.app.result-mode .screen {
  min-height: calc(100dvh - 74px);
}

.screen.is-leaving {
  pointer-events: none;
  animation: screen-out 1s ease both !important;
}

.chat-question {
  min-height: 100dvh;
  animation: screen-in 1s ease both;
}

.app.chat-mode .chat-question {
  min-height: auto;
  padding: 14px 13px 30px;
  scroll-margin-top: 104px;
  background: #f2f8f3;
}

.app.chat-mode .chat-question .progress {
  display: none;
}

.app.chat-mode .chat-question .question-title {
  margin: 10px 4px 8px;
  color: #33443a;
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: 0;
  text-align: left;
}

.app.chat-mode .chat-question .question-hint {
  margin: 0 4px;
  color: #6c7d73;
  font-size: 13px;
  line-height: 1.6;
  text-align: left;
}

.chat-question.is-leaving {
  pointer-events: none;
  animation: screen-out 1s ease both;
}

.app.chat-mode .result-card {
  min-height: auto;
}

.chat-loading {
  min-height: 45dvh;
}

.bubble {
  position: relative;
  max-width: 88%;
  padding: 13px 15px;
  border-radius: 3px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 18px;
  line-height: 1.65;
  animation: gentle-reveal 1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.chat-row--user {
  justify-content: flex-end;
}

.chat-row--image {
  display: block;
  width: auto;
  margin: -12px -9px 6px;
}

.chat-avatar {
  display: grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #b9d4c2;
  border-radius: 50%;
  background: #e3f1e7;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.chat-avatar__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-message-image {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
  border-radius: 0;
  animation: gentle-reveal 1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.app.chat-mode .bubble {
  max-width: 338px;
  padding: 11px 14px;
  border-radius: 3px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.7;
}

.app.chat-mode .bubble--bot {
  background: var(--white);
  color: #4d554f;
}

.app.chat-mode .bubble--user {
  background: var(--green);
  color: var(--white);
}

.app.chat-mode .bubble::before {
  display: none;
}

.bubble--bot {
  align-self: flex-start;
  background: var(--green);
  color: var(--white);
  border-bottom-left-radius: 3px;
}

.bubble--user {
  align-self: flex-end;
  background: var(--green-dark);
  color: var(--white);
  border-bottom-right-radius: 3px;
}

.bubble::before {
  content: "";
  position: absolute;
  top: 10px;
  width: 0;
  height: 0;
  border-style: solid;
}

.bubble--bot::before {
  left: -8px;
  border-width: 5px 9px 5px 0;
  border-color: transparent var(--green) transparent transparent;
}

.bubble--user::before {
  right: -8px;
  border-width: 5px 0 5px 9px;
  border-color: transparent transparent transparent var(--green-dark);
}

.question-block {
  padding: 28px 20px 30px;
}

.message-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px 0;
  text-align: center;
  overflow: hidden;
}

.message-screen__copy {
  width: 100%;
}

.message-screen__copy p {
  margin: 0 0 30px;
  color: var(--green-dark);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.7;
  letter-spacing: 0.025em;
  white-space: pre-wrap;
}

.message-screen__copy p:last-child {
  margin-bottom: 0;
}

.message-screen__copy .message-screen__body {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.8;
  letter-spacing: 0.02em;
}

.message-screen .message-character {
  width: 94px;
  margin: 46px auto -16px;
}

.message-screen .character--wide.message-character {
  width: 150px;
}

.action-screen {
  justify-content: flex-start;
  padding-top: 54px;
  padding-bottom: 36px;
}

.action-screen .intro-message--1 {
  font-size: 13px;
}

.action-screen .intro-message--2,
.action-screen .intro-message--3 {
  font-size: 20px;
}

.action-screen .cta-btn {
  flex: 0 0 auto;
  margin-top: 28px;
}

.progress {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.12em;
  margin: 6px 0 12px;
  animation: gentle-reveal 1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.question-title {
  margin: 0;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.55;
  letter-spacing: 0.015em;
  white-space: pre-line;
  animation: gentle-reveal 1s 0.08s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.question-hint {
  margin: 5px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  animation: gentle-reveal 1s 0.14s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.character {
  display: block;
  width: 64px;
  height: auto;
  margin: 10px auto -5px;
  animation: gentle-reveal 1s 0.18s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.character--wide {
  width: 128px;
  margin-top: 10px;
  margin-bottom: 14px;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.app.chat-mode .choice-list {
  margin: 18px 4px 0;
  gap: 8px;
}

.app.chat-mode .choice {
  min-height: 44px;
  border: 1px solid #b9d4c2;
  border-radius: 4px;
  background: var(--white);
  color: #435049;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  padding: 10px 12px;
}

.app.chat-mode .choice:hover {
  border-color: var(--green);
  background: #f7fbf8;
}

.app.chat-mode .choice.is-selected {
  border-color: var(--green);
  background: var(--green);
  color: var(--white);
}

.diagnosis-stage {
  padding-bottom: 34px;
}

.diagnosis-stage.is-updating {
  animation: none;
}

.diagnosis-stage__title {
  margin: 8px 4px 18px;
  color: #33443a;
  font-size: 16px;
  font-weight: 800;
}

.diagnosis-question {
  margin: 0 4px 18px;
  padding: 0 0 18px;
  border: 0;
  border-bottom: 1px solid #dce8df;
}

.diagnosis-question legend {
  margin: 0 0 9px;
  padding: 0;
  color: #33443a;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.65;
}

.diagnosis-question__note {
  margin: -3px 0 9px;
  color: #728078;
  font-size: 12px;
  line-height: 1.5;
}

.diagnosis-options {
  display: grid;
  gap: 8px;
}

.diagnosis-option {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #b9d4c2;
  border-radius: 4px;
  background: var(--white);
  color: #435049;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  cursor: pointer;
}

.diagnosis-option:hover {
  border-color: var(--green);
  background: #f7fbf8;
}

.diagnosis-option.is-selected {
  border-color: var(--green);
  background: var(--green);
  color: var(--white);
}

.diagnosis-next {
  display: block;
  width: calc(100% - 8px);
  min-height: 46px;
  margin: 4px 4px 0;
  padding: 10px 18px;
  border: 0;
  border-radius: 5px;
  background: var(--green);
  color: var(--white);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.diagnosis-next:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.completed-exchange {
  height: 1px;
  margin: 6px 0 10px;
  background: #dce8df;
}

.result-reason {
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1px solid #b9d4c2;
  border-radius: 4px;
  background: #f7fbf8;
  color: #435049;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.7;
}

.choice {
  appearance: none;
  position: relative;
  overflow: hidden;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: var(--green);
  color: var(--white);
  min-height: 50px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.55;
  padding: 11px 14px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
  animation: gentle-reveal 1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.choice__label {
  position: relative;
  z-index: 1;
}

.choice.is-confirming::before,
.choice.is-confirmed::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  background: var(--green-dark);
  content: "";
  pointer-events: none;
  transform: scaleX(0);
  transform-origin: left center;
}

.choice.is-confirming::before {
  animation: choice-meter 3s linear forwards;
}

.choice.is-confirmed::before {
  transform: scaleX(1);
}

.choice:nth-child(1) {
  animation-delay: 0.24s;
}

.choice:nth-child(2) {
  animation-delay: 0.3s;
}

.choice:nth-child(3) {
  animation-delay: 0.36s;
}

.choice:nth-child(4) {
  animation-delay: 0.42s;
}

.choice:nth-child(5) {
  animation-delay: 0.48s;
}

.choice:nth-child(6) {
  animation-delay: 0.54s;
}

.choice:nth-child(7) {
  animation-delay: 0.6s;
}

.choice:hover {
  background: var(--green-hover);
}

.choice:active {
  transform: scale(0.985);
}

.choice.is-selected {
  background: var(--green-dark);
}

.choice--check {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding-left: 14px;
  padding-right: 14px;
}

.check-mark {
  display: none;
}

.choice.is-selected .check-mark::after {
  content: none;
}

.next-btn,
.cta-btn {
  appearance: none;
  display: block;
  width: 100%;
  margin-top: 10px;
  border: 0;
  border-radius: var(--radius);
  background: var(--green-dark);
  color: var(--white);
  min-height: 50px;
  font-size: 17px;
  font-weight: 700;
  padding: 10px 14px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  animation: gentle-reveal 1s 0.66s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.next-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.cta-btn {
  background: var(--green);
}

.cta-btn:hover,
.next-btn:not(:disabled):hover {
  filter: brightness(1.05);
}

.result-card {
  padding: 8px 31px 36px;
  padding-top: 32px;
}

.result-card .question-title {
  font-size: 21px;
}

.result-lead {
  margin: 16px 0 0;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  white-space: pre-line;
}

.yureru-j {
  animation: yureru-j 2s infinite;
}

@keyframes yureru-j {
  0% {
    transform: translate(0px, 2px);
  }
  5% {
    transform: translate(0px, -2px);
  }
  10% {
    transform: translate(0px, 2px);
  }
  15% {
    transform: translate(0px, -2px);
  }
  20% {
    transform: translate(0px, 2px);
  }
  25% {
    transform: translate(0px, -2px);
  }
  30% {
    transform: translate(0px, 0px);
  }
}

.result-amount-wrap {
  margin: 20px 0;
  text-align: center;
}

.result-amount {
  margin: 8px 0;
  font-size: 28px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: 0.02em;
}

.result-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.summary-list {
  margin: 20px 0 0;
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--white);
  box-shadow: var(--shadow);
  list-style: none;
}

.summary-list li {
  font-size: 17px;
  padding: 6px 0;
}

.result-body {
  margin: 20px 0 0;
  font-size: 18px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.loading {
  padding: 48px 24px 64px;
  text-align: center;
}

.loading p {
  margin: 20px 0 0;
  font-size: 18px;
  font-weight: 500;
}

.dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  animation: bounce 1s infinite ease-in-out;
}

.dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-7px);
    opacity: 1;
  }
}

@keyframes gentle-reveal {
  from {
    opacity: 0;
    filter: blur(7px);
    transform: translateY(10px) scale(0.99);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
  }
}

@keyframes choice-meter {
  to {
    transform: scaleX(1);
  }
}

@keyframes screen-in {
  from {
    opacity: 0;
    filter: blur(7px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}

@keyframes screen-out {
  from {
    opacity: 1;
    filter: blur(0);
  }
  to {
    opacity: 0;
    filter: blur(7px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bubble,
  .progress,
  .question-title,
  .question-hint,
  .character,
  .choice,
  .next-btn,
  .cta-btn,
  .site-footer__logo,
  .chat-message-image,
  .result-card {
    animation: none;
  }

  .screen,
  .screen.is-leaving {
    animation: none !important;
  }
}

@media (min-width: 768px) {
  body {
    padding: 24px 0;
  }

  .screen {
    min-height: calc(100dvh - 48px);
  }

  .app.opening-mode .screen,
  .app.result-mode .screen {
    min-height: calc(100dvh - 122px);
  }

  .app {
    min-height: calc(100dvh - 48px);
    border-radius: 0;
    box-shadow: var(--shadow);
    overflow: hidden;
  }
}
