* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #18181c; /* 完全不透明な黒ベース */
}

/* 背景画像レイヤー（スライダーで透過） */
.bg-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('images/background.png');
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0.85;
  z-index: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
}

/* 全体コンテナ（iPhoneのSafeArea対応） */
.app-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* 動的ビューポート対応 */
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ヘッダー */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: rgba(20, 20, 25, 0.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-title {
  color: #ffffff;
  font-size: 16px;
  font-weight: bold;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-label {
  color: #bbbbbb;
  font-size: 11px;
}

#opacitySlider {
  width: 65px;
  accent-color: #147efb;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}

/* チャットタイムライン */
.chat-timeline {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

/* 吹き出し共通 */
.message-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 85%;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background-color: #333;
}

.bubble {
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

/* 灯織（左側） */
.message-row.hiori {
  align-self: flex-start;
}
.message-row.hiori .bubble {
  background: rgba(255, 255, 255, 0.92);
  color: #111111;
  border-bottom-left-radius: 4px;
}

/* ユーザー（右側） */
.message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.message-row.user .bubble {
  background: #85e25d;
  color: #111111;
  border-bottom-right-radius: 4px;
}

/* 入力バー */
.chat-input-bar {
  display: flex;
  padding: 8px 12px;
  gap: 8px;
  background: rgba(20, 20, 25, 0.75);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#messageInput {
  flex: 1;
  border: none;
  outline: none;
  border-radius: 18px;
  padding: 8px 14px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.9);
  color: #111111;
  resize: none;
  max-height: 100px;
  min-height: 36px;
  line-height: 20px;
}

.send-btn {
  background-color: #147efb;
  color: #ffffff;
  border: none;
  outline: none;
  border-radius: 18px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
}

.send-btn:disabled {
  opacity: 0.5;
}

/* 設定モーダル */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: #25252a;
  color: #fff;
  padding: 20px;
  border-radius: 12px;
  width: 85%;
  max-width: 320px;
}

.modal-content h3 { margin-bottom: 8px; font-size: 16px; }
.modal-content p { font-size: 12px; color: #aaa; margin-bottom: 12px; }
.modal-content input {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #18181c;
  color: #fff;
  margin-bottom: 16px;
}
.modal-buttons { display: flex; justify-content: flex-end; gap: 8px; }
.primary-btn { background: #147efb; color: #fff; border: none; padding: 6px 12px; border-radius: 6px; }
.cancel-btn { background: #444; color: #fff; border: none; padding: 6px 12px; border-radius: 6px; }