:root {
  --ink: #1f1f1f;
  --ink-soft: #5b5b5b;
  --green: #278a4f;
  --green-dark: #1f6f40;
  --gold: #cdb581;
  --gold-soft: #e9dfc4;
  --beige: #edeae6;
  --paper: #ffffff;
  --line: #e2ded7;
  --bg: #f4f2ee;
  --radius: 14px;
  --font: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #d9d5cf;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.6;
}

/* スマホでは全画面、PCでは中央に端末幅で表示 */
@media (max-width: 639px) {
  /* ページ自体はスクロールさせず、チャット欄だけをスクロールさせる（キーボード表示時のズレ防止） */
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  body { position: fixed; inset: 0; width: 100%; }
}
.phone {
  display: flex;
  flex-direction: column;
  height: var(--app-h, 100dvh);
  max-width: 430px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}
@media (min-width: 640px) {
  body { min-height: 100vh; padding: 28px 0 40px; background: radial-gradient(circle at 30% 20%, #e7e2d9, #cfcac2); }
  /* 端末風のベゼル（スマホ表示イメージ） */
  .stage { width: 418px; margin: 0 auto; }
  .device {
    padding: 14px; border-radius: 48px; background: #17171a;
    box-shadow: 0 40px 80px rgba(0,0,0,.35), inset 0 0 0 2px #3a3a3f;
    position: relative;
  }
  .device::before { /* ノッチ */
    content: ""; position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
    width: 120px; height: 26px; background: #17171a; border-radius: 0 0 18px 18px; z-index: 5;
  }
  .phone { width: 390px; height: 780px; max-height: calc(100vh - 140px); min-height: 600px; border-radius: 36px; overflow: hidden; }
}

/* header */
.hdr {
  background: var(--ink);
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  border-bottom: 2px solid var(--green);
}
.hdr-brand { display: flex; flex-direction: column; line-height: 1.1; }
.hdr-logo { font-family: "Cormorant Garamond", "Times New Roman", serif; font-style: italic; font-size: 22px; letter-spacing: .08em; color: var(--gold); }
.hdr-name { font-size: 10px; color: #cfcfcf; letter-spacing: .12em; }
.hdr-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.hdr-avatar { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--gold); background: var(--beige); }
.hdr-title-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.hdr-title-main { font-weight: 700; font-size: 15px; }
.hdr-title-sub { font-size: 10.5px; color: #bdbdbd; }

/* chat */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 92%; }
.msg.bot { align-self: flex-start; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.avatar {
  flex: 0 0 32px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--beige); object-fit: cover;
  box-shadow: 0 0 0 1px var(--gold-soft);
}
.bubble {
  padding: 10px 13px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg.bot .bubble { border-bottom-left-radius: 4px; }
.msg.user .bubble { background: var(--green); color: #fff; border-color: var(--green); border-bottom-right-radius: 4px; }
.bubble p { margin: 0 0 6px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 4px 0 6px; padding-left: 1.1em; }
.bubble li { margin: 2px 0; }
.bubble a { color: var(--green-dark); text-decoration: underline; }
.msg.user .bubble a { color: #fff; }
.bubble strong { font-weight: 700; }

/* menu cards */
.menu-list { display: flex; flex-direction: column; gap: 6px; margin-left: 40px; max-width: 92%; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; font: inherit; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 10px; padding: 10px 12px; cursor: pointer;
  transition: background .12s, transform .08s;
}
.menu-item:active { transform: scale(.985); }
.menu-item:hover { background: #fbfaf7; }
.menu-item .mi-text { display: flex; flex-direction: column; line-height: 1.3; }
.menu-item .mi-label { font-weight: 500; font-size: 14.5px; }
.menu-item .mi-hint { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }
.menu-item .mi-chev { color: var(--gold); flex: 0 0 auto; }
.menu-item.back { border-left-color: #bbb; color: var(--ink-soft); font-size: 13px; padding: 8px 12px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-left: 40px; max-width: 92%; }
.chip {
  font: inherit; font-size: 13px; color: var(--ink);
  background: #fff; border: 1px solid var(--gold); border-radius: 999px;
  padding: 6px 12px; cursor: pointer;
}
.chip:hover { background: var(--gold-soft); }
.chip.ghost { border-color: #c9c4bb; color: var(--ink-soft); }

/* actions */
.actions { display: flex; flex-direction: column; gap: 6px; margin-left: 40px; max-width: 92%; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 14.5px; font-weight: 700; text-decoration: none;
  padding: 12px 14px; border-radius: 10px; cursor: pointer;
  border: 1.5px solid var(--green); color: var(--green-dark); background: #fff;
}
.btn.primary { background: var(--green); color: #fff; box-shadow: 0 4px 12px rgba(39,138,79,.25); }

/* typing */
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #b9b3a8; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.note { font-size: 11px; color: var(--ink-soft); margin-left: 40px; }

/* 「続きを見る」 */
.more-hint {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 76px; z-index: 3;
  font: inherit; font-size: 12.5px; color: #fff; background: rgba(31,31,31,.85);
  border: none; border-radius: 999px; padding: 6px 14px; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

/* feedback */
.feedback { display: flex; align-items: center; gap: 6px; margin-left: 40px; font-size: 11.5px; color: var(--ink-soft); }
.feedback button { font: inherit; font-size: 14px; background: #fff; border: 1px solid var(--line); border-radius: 999px; width: 30px; height: 30px; cursor: pointer; }
.feedback button:hover { border-color: var(--gold); background: var(--gold-soft); }

/* composer */
.composer {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 8px 10px calc(6px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line);
}
.disclaimer { flex: 1 0 100%; margin: 0; font-size: 10px; line-height: 1.4; color: #8a8378; text-align: center; }
.menu-btn {
  flex: 0 0 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--beige); color: var(--ink); display: grid; place-items: center; cursor: pointer;
}
.input-form { flex: 1; display: flex; gap: 6px; }
.input-form input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; /* iOSのズーム防止 */
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fbfaf7;
}
.input-form input:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
.input-form button {
  flex: 0 0 42px; height: 42px; border-radius: 10px; border: none;
  background: var(--green); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.input-form button:disabled { background: #b9b3a8; }

/* PC表示: ノッチ分だけヘッダーを下げる（.hdr の padding 指定より後に置く） */
@media (min-width: 640px) {
  .hdr { padding-top: 36px; }
}
