:root {
  color-scheme: light;
  --bg: #fff9f8;
  --surface: #ffffff;
  --surface-warm: #fffdfc;
  --navy: #26255f;
  --muted: #777895;
  --border: #d8d7e6;
  --border-strong: #c6c5dc;
  --blush: #f4d6d7;
  --blush-deep: #e8b7ba;
  --peach: #fff0e8;
  --peach-strong: #f4b9a8;
  --line: #06c755;
  --danger-bg: #fff4f1;
  --danger: #8b3f45;
  --focus: #696aa4;
  --shadow: 0 8px 30px rgba(38, 37, 95, 0.06);
  --radius-lg: 18px;
  --radius-md: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--navy);
}

body {
  overscroll-behavior-y: none;
}

body:has(dialog[open]) {
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button,
a {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(38, 37, 95, 0.12);
}

.app-shell {
  width: min(100%, 430px);
  height: 100dvh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: relative;
  overflow: hidden;
}

.app-header {
  min-height: 82px;
  padding: max(14px, env(safe-area-inset-top)) 18px 13px;
  background: rgba(255, 249, 248, 0.96);
  border-bottom: 1px solid rgba(216, 215, 230, 0.65);
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}

.back-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.back-button svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.back-button:active {
  background: rgba(38, 37, 95, 0.07);
}

.app-heading {
  grid-column: 2;
  text-align: center;
}

.app-heading h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.35;
  letter-spacing: 0.025em;
  font-weight: 700;
}

.app-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.conversation {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 16px 26px;
  scroll-behavior: smooth;
}

.welcome-visual {
  width: 118px;
  height: 112px;
  margin: 0 auto 14px;
  overflow: hidden;
  border-radius: 44% 44% 46% 46%;
  background: radial-gradient(circle at 52% 52%, #ffffff 0 28%, #fff0ea 68%, #ffe2d7 100%);
  box-shadow: 0 10px 26px rgba(232, 183, 186, 0.17);
}

.welcome-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  filter: brightness(1.08) saturate(1.2) contrast(0.94);
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 14px;
}

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

.avatar-shell {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 2px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffd9c9, #fff6ef);
  box-shadow: 0 3px 11px rgba(174, 112, 91, 0.18);
  position: relative;
}

.avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 22%;
  background: #fff7f1;
  filter: brightness(1.14) saturate(1.25) contrast(0.92);
}

.online-dot {
  width: 9px;
  height: 9px;
  position: absolute;
  right: -1px;
  bottom: -1px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--line);
}

.bubble {
  max-width: min(80%, 310px);
  padding: 13px 15px;
  border-radius: var(--radius-lg);
  font-size: 15px;
  line-height: 1.68;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.bubble p {
  margin: 0;
}

.bubble p + p {
  margin-top: 11px;
}

.assistant-bubble {
  background: var(--surface-warm);
  border: 1px solid #e5deda;
  border-top-left-radius: 6px;
}

.user-bubble {
  background: var(--blush);
  border: 1px solid rgba(232, 183, 186, 0.7);
  border-bottom-right-radius: 6px;
}

.prompt-label {
  margin: 2px 0 10px;
  color: #676884;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 700;
  text-align: center;
}

.quick-prompts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 14px;
}

.quick-prompts button {
  min-height: 84px;
  padding: 10px 5px 8px;
  border: 1.5px solid #edc9c3;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #ffffff 0%, #fff4ef 100%);
  box-shadow: 0 4px 12px rgba(136, 88, 81, 0.09);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  line-height: 1.25;
  font-weight: 650;
  cursor: pointer;
  transition: transform 110ms ease, box-shadow 110ms ease, background 110ms ease, border-color 110ms ease;
}

.quick-prompts button:active,
.quick-prompts button.tap-feedback {
  background: #ffe7de;
  border-color: var(--peach-strong);
  box-shadow: 0 1px 4px rgba(136, 88, 81, 0.14);
  transform: translateY(2px) scale(0.975);
}

.quick-prompts button:disabled {
  opacity: 0.55;
  cursor: default;
}

.quick-prompts svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.quick-prompts small {
  color: #9a6660;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 600;
}

@media (min-width: 356px) {
  .quick-prompts span {
    font-size: 11px;
    white-space: nowrap;
  }
}

.usage-note {
  margin: 2px 0 12px 42px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  text-align: right;
}

.safety-notice {
  width: min(100%, 310px);
  margin: 0 auto 18px;
  padding: 10px 12px;
  border: 0;
  border-left: 4px solid #8889af;
  border-radius: 8px;
  color: #686a84;
  background: #f2f1f7;
}

.safety-notice-title {
  display: grid;
  grid-template-columns: 20px auto 20px;
  align-items: center;
  justify-content: center;
  column-gap: 8px;
}

.safety-notice-title::after {
  width: 20px;
  height: 20px;
  content: "";
}

.safety-notice svg {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  fill: none;
  stroke: var(--navy);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.safety-notice p {
  margin: 7px 0 0;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.safety-notice strong {
  color: #515372;
  font-size: 11px;
  line-height: 1.35;
}

.line-return {
  width: fit-content;
  margin: 8px auto 0;
  padding: 8px 5px;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: #5f628f;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  display: block;
}

.line-invite,
.beta-invite,
.limit-notice {
  width: min(80%, 310px);
  margin: 4px 0 18px 42px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
}

.line-invite[hidden],
.beta-invite[hidden],
.limit-notice[hidden] {
  display: none;
}

.line-invite h2,
.beta-invite h2,
.limit-notice h2 {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0.01em;
}

.line-invite p,
.beta-invite p,
.limit-notice p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.58;
}

.line-invite {
  border-color: rgba(6, 199, 85, 0.34);
  background: linear-gradient(145deg, #ffffff 0%, #f2fff7 100%);
  box-shadow: 0 8px 22px rgba(6, 199, 85, 0.08);
}

.line-invite a {
  min-height: 48px;
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 14px;
  background: var(--line);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 750;
  text-decoration: none;
  box-shadow: 0 6px 14px rgba(6, 199, 85, 0.18);
  transition: transform 110ms ease, filter 110ms ease;
}

.line-invite a:active {
  transform: scale(0.98);
  filter: brightness(0.94);
}

.line-invite a svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.beta-invite a {
  min-height: 44px;
  margin-top: 12px;
  padding: 10px 13px;
  border-radius: 13px;
  background: var(--navy);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 700;
  text-decoration: none;
}

.beta-invite a svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.limit-notice {
  border-color: #e4cccd;
  background: #fff5f3;
}

.typing-bubble {
  min-width: 64px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.typing-bubble span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 1.15s infinite ease-in-out;
}

.typing-bubble span:nth-child(2) {
  animation-delay: 0.14s;
}

.typing-bubble span:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.composer {
  padding: 9px 14px calc(12px + var(--safe-bottom));
  border-top: 1px solid rgba(216, 215, 230, 0.75);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -8px 24px rgba(38, 37, 95, 0.035);
  z-index: 10;
}

.privacy-details {
  margin: 0 1px 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.privacy-details summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.privacy-details summary::-webkit-details-marker {
  display: none;
}

.privacy-details svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: var(--navy);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.privacy-details p {
  margin: 7px 0 0 22px;
  padding: 8px 10px;
  border-radius: 9px;
  background: #f7f5f8;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 9px;
  align-items: end;
}

textarea {
  width: 100%;
  min-height: 48px;
  max-height: 116px;
  resize: none;
  border: 1px solid var(--border-strong);
  border-radius: 17px;
  background: var(--surface);
  color: var(--navy);
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.5;
  outline: none;
}

textarea::placeholder {
  color: #a5a5b8;
}

textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(105, 106, 164, 0.13);
}

.send-button {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--navy);
  color: white;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

.send-button:active:not(:disabled) {
  transform: scale(0.94);
}

.send-button:disabled {
  opacity: 0.32;
  cursor: default;
}

.send-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.error-bubble {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #efd1cc;
}

.crisis-bubble {
  color: #66343a;
  background: #fff0ec;
  border-color: #e9bbb5;
}

.consent-dialog {
  width: min(calc(100% - 32px), 398px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 24px 20px 18px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  color: var(--navy);
  box-shadow: 0 28px 80px rgba(38, 37, 95, 0.22);
}

.consent-dialog::backdrop {
  background: rgba(31, 30, 64, 0.42);
  backdrop-filter: blur(4px);
}

.consent-visual {
  width: 80px;
  height: 76px;
  margin: -6px auto 8px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--bg);
}

.consent-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  mix-blend-mode: multiply;
}

.consent-dialog h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.4;
  text-align: center;
}

.consent-copy {
  margin-top: 15px;
  padding: 14px;
  border-radius: 15px;
  background: #f8f6f8;
}

.consent-copy p {
  margin: 0;
  color: #555778;
  font-size: 13px;
  line-height: 1.65;
}

.consent-copy p + p {
  margin-top: 9px;
}

.consent-actions {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 0.8fr 1.4fr;
  gap: 9px;
}

.consent-actions button {
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 15px;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 700;
  cursor: pointer;
}

.secondary-action {
  border: 1px solid var(--border-strong);
  background: #ffffff;
}

.primary-action {
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #ffffff;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid rgba(105, 106, 164, 0.38);
  outline-offset: 2px;
}

@media (min-width: 431px) {
  body {
    background: #f3eff1;
  }

  .app-shell {
    box-shadow: var(--shadow);
  }
}

@media (max-width: 355px) {
  .conversation {
    padding-inline: 12px;
  }

  .quick-prompts,
  .prompt-label {
    margin-left: 0;
  }

  .quick-prompts button {
    font-size: 11px;
  }

  .consent-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
