/* =============================================================
   味源 AIコンシェルジュ - スタイルシート
   v2: アバター縮小 + 横スワイプカード型ボタン対応
   ============================================================= */

:root {
  --black: #0A0A0A;
  --black-soft: #141210;
  --black-warm: #1A1612;
  --gold: #C9A961;
  --gold-light: #E8D89C;
  --gold-deep: #9A7F44;
  --cream: #FBF6EC;
  --cream-soft: #F4ECDA;
  --brown: #4A2C1F;
  --red-dark: #7A1F1A;
  --text-light: #E8E0CC;
  --text-mid: #B8A988;
  --border-gold: rgba(201, 169, 97, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

body {
  font-family: 'Noto Serif JP', 'Shippori Mincho', serif;
  background: var(--black);
  color: var(--text-light);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

input, button, textarea {
  font-family: inherit;
  color: inherit;
}

/* =============================================================
   レイアウト全体
   ============================================================= */
.app {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: var(--black);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

@media (min-width: 481px) {
  body {
    background:
      radial-gradient(circle at 50% 20%, #2a1a14 0%, transparent 60%),
      var(--black);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .app {
    height: 100vh;
    max-height: 900px;
    border-left: 1px solid var(--border-gold);
    border-right: 1px solid var(--border-gold);
    box-shadow: 0 0 60px rgba(0,0,0,0.8);
  }
}

/* =============================================================
   ヘッダー
   ============================================================= */
.header {
  background: var(--black);
  padding: 12px 18px;
  padding-top: calc(12px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-gold);
  flex-shrink: 0;
  z-index: 10;
}

.header-brand { display: flex; align-items: center; gap: 10px; }

.logo-mark {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
}

.logo-mark svg { width: 100%; height: 100%; }

.brand-text { display: flex; flex-direction: column; line-height: 1; }

.brand-name {
  font-family: 'Shippori Mincho', 'Noto Serif JP', serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--cream);
  letter-spacing: 3px;
}

.brand-sub {
  font-family: 'Cormorant Garamond', serif;
  font-size: 8px;
  color: var(--gold);
  letter-spacing: 3px;
  margin-top: 3px;
}

.lang-btn {
  background: transparent;
  border: 1px solid var(--border-gold);
  color: var(--gold);
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: 'Noto Serif JP', serif;
}

.lang-btn:active { transform: scale(0.96); }

/* =============================================================
   ヒーローエリア（★ コンパクト版 ★）
   ============================================================= */
.hero {
  position: relative;
  background: var(--black);
  overflow: hidden;
  flex-shrink: 0;
  height: 160px;  /* ★ 240px → 160px に縮小 */
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 70% 50%, rgba(201, 169, 97, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 30% 30%, rgba(122, 31, 26, 0.15) 0%, transparent 50%),
    var(--black-warm);
}

.hero-content {
  position: relative;
  display: flex;
  align-items: stretch;
  padding: 16px 0 0 20px;
  height: 100%;
}

.hero-text {
  flex: 1;
  padding-top: 12px;
  z-index: 2;
  max-width: 55%;
}

.hero-label {
  font-family: 'Cormorant Garamond', 'Noto Serif JP', serif;
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 3px;
  margin-bottom: 8px;
}

.hero-title {
  font-family: 'Shippori Mincho', 'Noto Serif JP', serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--cream);
  letter-spacing: 1.5px;
  line-height: 1.5;
}

/* アバターエリア（3枚重ね・縮小版） */
.hero-avatar {
  width: 45%;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
}

.avatar-layer {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  height: 100%;
  max-height: 170px;
  object-fit: cover;
  object-position: top center;
  opacity: 0;
  transition: opacity 0.7s ease-in-out;
  pointer-events: none;
}

.avatar-layer.active { opacity: 1; }

.avatar-placeholder {
  width: 100px;
  height: 140px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border-gold);
  border-radius: 4px;
  margin: 10px;
}

.avatar-placeholder.show { display: flex; }

.avatar-placeholder svg {
  width: 100%;
  height: 100%;
  opacity: 0.5;
}

/* =============================================================
   チャット領域（★ 拡大 ★）
   ============================================================= */
.chat {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 18px 8px;
  background: var(--black);
  min-height: 100px;
}

.chat::-webkit-scrollbar { width: 4px; }
.chat::-webkit-scrollbar-track { background: transparent; }
.chat::-webkit-scrollbar-thumb { background: var(--gold-deep); border-radius: 2px; }

.msg {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  animation: fadeUp 0.4s ease-out;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-ai { align-items: flex-start; }

.msg-user {
  flex-direction: row-reverse;
  align-items: flex-end;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border-gold);
  background: var(--black-warm);
  position: relative;
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.msg-avatar-fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: 'Shippori Mincho', serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--gold);
}

.msg-body { max-width: 78%; }

.msg-user .msg-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.msg-bubble {
  background: rgba(40, 30, 22, 0.85);
  color: var(--text-light);
  padding: 12px 16px;
  border-radius: 4px 16px 16px 16px;
  font-size: 14px;
  line-height: 1.85;
  font-family: 'Noto Serif JP', serif;
  font-weight: 400;
  letter-spacing: 0.5px;
  border: 1px solid rgba(201, 169, 97, 0.12);
}

.msg-user .msg-bubble {
  background: linear-gradient(135deg, var(--gold-deep) 0%, var(--gold) 100%);
  color: var(--black);
  border-radius: 16px 4px 16px 16px;
  font-weight: 500;
  border: none;
}

.msg-time {
  font-family: 'Cormorant Garamond', serif;
  font-size: 10px;
  color: var(--text-mid);
  margin-top: 4px;
  letter-spacing: 1px;
  padding-left: 4px;
}

.msg-user .msg-time { padding-right: 4px; padding-left: 0; }

.typing-bubble {
  display: inline-flex;
  gap: 4px;
  padding: 14px 18px;
}

.typing-bubble span {
  width: 6px;
  height: 6px;
  background: var(--gold);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

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

/* =============================================================
   ★★★ クイックボタン（横スワイプカード型）★★★
   ============================================================= */
.quick-grid {
  /* 横スクロール対応 */
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 10px 14px;
  background: var(--black);
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scroll-padding: 14px;
  /* スクロールバーを非表示 */
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* 右端のフェード効果用 */
  position: relative;
  mask-image: linear-gradient(to right, transparent 0, black 8px, black calc(100% - 24px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 8px, black calc(100% - 24px), transparent 100%);
}

.quick-grid::-webkit-scrollbar { display: none; }

.quick-btn {
  /* カード型に変更 */
  flex: 0 0 auto;
  width: 110px;
  height: 100px;
  background: linear-gradient(180deg, rgba(40, 30, 22, 0.7) 0%, rgba(20, 15, 10, 0.9) 100%);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  padding: 14px 8px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  color: var(--cream);
  scroll-snap-align: start;
  position: relative;
  overflow: hidden;
}

/* カード上部の金線（高級感） */
.quick-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 1px;
  background: var(--gold);
  opacity: 0.6;
}

.quick-btn:active {
  transform: scale(0.95);
  background: linear-gradient(180deg, var(--gold-deep) 0%, rgba(60, 45, 25, 0.9) 100%);
}

.quick-btn:active::before {
  background: var(--gold-light);
  opacity: 1;
}

.quick-icon {
  width: 26px;
  height: 26px;
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-icon svg { width: 100%; height: 100%; }

.quick-label {
  font-family: 'Noto Serif JP', serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--cream);
  text-align: center;
  line-height: 1.4;
  letter-spacing: 0.5px;
}

/* スワイプヒント（最初の1回だけ表示） */
.swipe-hint {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  background: rgba(201, 169, 97, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: swipeHint 1.5s ease-in-out infinite;
}

@keyframes swipeHint {
  0%, 100% { transform: translate(0, -50%); opacity: 0.7; }
  50% { transform: translate(-8px, -50%); opacity: 1; }
}

/* =============================================================
   入力エリア
   ============================================================= */
.input-area {
  background: var(--black);
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border-gold);
  flex-shrink: 0;
}

.mic-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-gold);
  color: var(--gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  transition: all 0.2s;
}

.mic-btn svg { width: 18px; height: 18px; }
.mic-btn:active { transform: scale(0.92); }

.mic-btn.listening {
  background: var(--red-dark);
  border-color: var(--red-dark);
  color: var(--cream);
}

.mic-pulse {
  position: absolute;
  inset: -3px;
  border: 2px solid var(--red-dark);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.mic-btn.listening .mic-pulse {
  animation: micPulse 1.5s infinite;
}

@keyframes micPulse {
  0% { opacity: 0.8; transform: scale(0.95); }
  100% { opacity: 0; transform: scale(1.4); }
}

.input-field {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border-gold);
  border-radius: 22px;
  padding: 11px 16px;
  font-size: 13px;
  color: var(--cream);
  font-family: 'Noto Serif JP', serif;
  outline: none;
  min-width: 0;
}

.input-field::placeholder { color: var(--text-mid); opacity: 0.6; }
.input-field:focus { border-color: var(--gold); }

.send-btn {
  background: linear-gradient(135deg, var(--gold-deep) 0%, var(--gold) 100%);
  border: none;
  color: var(--black);
  border-radius: 22px;
  padding: 11px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'Noto Serif JP', serif;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 2px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(201, 169, 97, 0.25);
}

.send-btn svg { width: 14px; height: 14px; }
.send-btn:active { transform: scale(0.96); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* =============================================================
   フッター
   ============================================================= */
.footer {
  background: var(--black);
  padding: 7px 18px 9px;
  padding-bottom: calc(7px + env(safe-area-inset-bottom));
  text-align: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 9px;
  color: var(--gold);
  letter-spacing: 1.5px;
  border-top: 1px solid var(--border-gold);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: 0.7;
}

/* =============================================================
   モーダル
   ============================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.show { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--black-warm);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-header {
  font-family: 'Shippori Mincho', serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--gold);
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: 3px;
}

.lang-option {
  background: transparent;
  border: 1px solid var(--border-gold);
  color: var(--cream);
  padding: 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Noto Serif JP', serif;
  font-size: 14px;
  letter-spacing: 1px;
}

.lang-option.active {
  background: var(--gold-deep);
  color: var(--black);
  border-color: var(--gold);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-mid);
  padding: 12px;
  font-family: 'Noto Serif JP', serif;
  font-size: 12px;
  cursor: pointer;
  margin-top: 8px;
}

/* =============================================================
   レスポンシブ調整
   ============================================================= */
@media (max-height: 700px) {
  .hero { height: 140px; }
  .hero-title { font-size: 15px; }
  .avatar-layer { max-height: 150px; }
  .quick-btn { width: 100px; height: 90px; }
}

@media (max-width: 360px) {
  .hero-title { font-size: 15px; }
  .brand-name { font-size: 16px; letter-spacing: 2px; }
  .quick-btn { width: 100px; }
}
