/* ============ CHAT PAGE ============ */
body {
  font-family: 'Zen Kaku Gothic New', sans-serif;
  background: var(--paper);
  color: var(--ink);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main {
  flex: 1;
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* スマホフレーム */
.chat-outer {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 32px 0 0;
  flex: 1;
  overflow: hidden;
}

.phone-frame {
  width: 440px;
  height: min(550px, calc(100vh - 180px));
  background: white;
  border-radius: 48px 48px 0 0;
  border: 10px solid #1a1a2e;
  border-bottom: none;
  box-shadow: 0 0 0 2px #444, 0 -4px 0 2px #444, 24px 40px 80px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.phone-notch {
  background: #1a1a2e;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.phone-notch-bar {
  width: 110px;
  height: 8px;
  background: #333;
  border-radius: 4px;
}

.phone-chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--paper);
  scroll-behavior: smooth;
}

.phone-chat-area::-webkit-scrollbar {
  width: 3px;
}

.phone-chat-area::-webkit-scrollbar-track {
  background: transparent;
}

.phone-chat-area::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 2px;
}

.phone-input-area {
  padding: 10px 14px 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: white;
  flex-shrink: 0;
}

/* スマホ実機では全幅・フレームなし */
@media(max-width:500px) {
  .chat-outer {
    padding: 0;
  }

  .phone-frame {
    width: 100%;
    height: calc(100dvh - (70px + 41px + 59px));
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  .phone-notch {
    display: none;
  }
}

/* メッセージ */
.message {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  animation: fadeUp 0.3s ease both;
}

.message.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar.user {
  font-size: 18px;
}

.avatar-label {
  font-size: 9px;
  color: var(--muted);
  text-align: center;
  margin-top: 3px;
  width: 50px;
}

.avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.7;
}

.bubble.ai {
  background: white;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--ink);
}

.bubble.user {
  background: var(--user-bubble);
  color: white;
  border-bottom-right-radius: 4px;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.choice-btn {
  background: var(--paper);
  border: 1.5px solid var(--border);
  color: var(--ink);
  padding: 7px 13px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

.choice-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.choice-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* 提案カード */
.output-card h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
}

.output-section {
  margin-bottom: 12px;
}

.output-section-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.output-text {
  font-size: 12px;
  line-height: 1.75;
  background: #f5f2eb;
  padding: 8px 10px;
  border-left: 2px solid var(--border);
}

.title-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.title-list li {
  font-size: 12px;
  padding: 6px 10px;
  background: #f5f2eb;
  border-left: 2px solid var(--ink);
  font-weight: 500;
}

/* 見積カード */
.estimate-card {
  background: var(--ink);
  color: white;
  padding: 14px 16px;
  margin-top: 8px;
  border-radius: 8px;
}

.estimate-price {
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 4px;
}

.estimate-price span {
  font-size: 12px;
  opacity: 0.55;
  font-weight: 400;
  margin-left: 4px;
}

.estimate-note {
  font-size: 10px;
  opacity: 0.55;
  margin-bottom: 12px;
  line-height: 1.6;
}

.estimate-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.estimate-item {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.estimate-item:last-child {
  border-bottom: none;
}

/* インプット */
.input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.input-box {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink);
  background: var(--paper);
  resize: none;
  min-height: 42px;
  max-height: 100px;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.5;
}

.input-box:focus {
  border-color: var(--ink);
}

.input-box::placeholder {
  color: var(--muted);
}

.send-btn {
  background: var(--ink);
  color: white;
  border: none;
  padding: 0 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  height: 42px;
  display: flex;
  align-items: center;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.send-btn:hover {
  background: var(--accent);
}

.reset-btn {
  font-size: 10px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  margin-top: 8px;
  margin-left: 16px;
  text-decoration: underline;
}

.reset-btn:hover {
  color: var(--accent);
}

/* タイピング */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 8px 0;
}

.typing-dot {
  width: 5px;
  height: 5px;
  background: var(--muted);
  border-radius: 50%;
  animation: blink 1.2s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {

  0%,
  80%,
  100% {
    opacity: 0.2
  }

  40% {
    opacity: 1
  }
}
