*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: #06061a;
}

#app {
  width: 100%;
  height: 100%;
}

header {
  position: fixed;
  top: var(--vv-top, 0px); /* iPhone がキーボードを開いたときに画面をずらしても、見えている範囲の上に出す */
  left: 0;
  right: 0;
  z-index: 10;
  background: #0d0830;
  color: #f0e8ff;
  padding: 14px 20px;
  padding-top: calc(14px + env(safe-area-inset-top, 0));
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 2px solid #e040e0;
  box-shadow: 0 0 24px rgba(224, 64, 224, 0.5), 0 2px 6px rgba(0,0,0,.4);
}
header .material-symbols-outlined {
  font-size: 1.8rem;
  color: #e040e0;
  filter: drop-shadow(0 0 6px #e040e0);
}
header h1 { font-size: 1.05rem; font-weight: 700; letter-spacing: .03em; }
header p  { font-size: .72rem; opacity: .75; margin-top: 1px; }
.header-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px #e040e0);
}

.material-symbols-outlined { user-select: none; }

#chat {
  position: fixed;
  top: calc(var(--header-h, 62px) + var(--vv-top, 0px));
  bottom: calc(var(--input-h, 70px) + var(--kb, 0px) + 22px);
  left: 0;
  right: 0;
  overflow-y: auto;
  padding: 16px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #06061a;
  -webkit-overflow-scrolling: touch;
}

/* bot アバター付きの行 */
.bot-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  align-self: flex-start;
  max-width: 88%;
}

.bot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4b1d9e, #e040e0);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  box-shadow: 0 0 12px rgba(224, 64, 224, 0.7);
}
.bot-avatar .material-symbols-outlined { font-size: 1.1rem; }
.bot-avatar-img { width: 88%; height: 88%; object-fit: contain; }

.bot-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.label {
  font-size: .68rem;
  color: #6bff80;
  margin-bottom: 1px;
  padding: 0 2px;
  text-shadow: 0 0 6px rgba(107, 255, 128, 0.8);
}

.bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: .93rem;
  line-height: 1.65;
  word-break: break-word;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble-text {
  white-space: pre-wrap;
}

.menu-loading {
  font-size: .82rem;
  color: #9988cc;
}

.bubble.bot-bubble {
  background: #0f0a30;
  color: #e8e8ff;
  border: 1.5px solid #6bff80;
  border-bottom-left-radius: 4px;
  box-shadow: 0 0 10px rgba(107, 255, 128, 0.35), inset 0 0 10px rgba(107, 255, 128, 0.05);
}

/* ユーザー吹き出し */
.user-row {
  display: flex;
  align-self: flex-end;
  max-width: 78%;
}

.bubble.user-bubble {
  background: linear-gradient(135deg, #8b10a0, #e040e0);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 0 14px rgba(224, 64, 224, 0.6);
}

/* 選択肢ボタン（bubble 内に配置） */
.choices-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-btn {
  background: transparent;
  color: #6bff80;
  border: 1.5px solid #6bff80;
  border-radius: 20px;
  padding: 7px 16px;
  font-size: .85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 0 8px rgba(107, 255, 128, 0.35);
  word-break: auto-phrase;
}
.quick-btn:hover {
  background: #6bff80;
  color: #06061a;
  box-shadow: 0 0 18px rgba(107, 255, 128, 0.8);
}
.quick-btn:active { opacity: .8; }

.return-btn {
  color: #e040e0;
  border-color: #e040e0;
  box-shadow: 0 0 8px rgba(224, 64, 224, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.return-btn .material-symbols-outlined { font-size: 1rem; }
.return-btn:hover {
  background: #e040e0;
  color: #fff;
  box-shadow: 0 0 18px rgba(224, 64, 224, 0.8);
}

/* スピナー */
.spinner-wrap { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.spinner {
  width: 20px; height: 20px;
  border: 3px solid #2a1a5e;
  border-top-color: #6bff80;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(107, 255, 128, 0.5);
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-wrap span { font-size: .83rem; color: #9988cc; }

/* AI 免責注意書き */
#ai-disclaimer {
  position: fixed;
  bottom: calc(var(--input-h, 70px) + var(--kb, 0px));
  left: 0;
  right: 0;
  z-index: 9;
  text-align: center;
  font-size: .65rem;
  color: rgba(153, 136, 204, 0.5);
  padding: 3px 12px;
  background: #06061a;
  pointer-events: none;
  user-select: none;
  letter-spacing: .01em;
}
body.light-mode #ai-disclaimer {
  background: #f0f4f8;
  color: rgba(107, 114, 128, 0.55);
}

/* 入力欄（視覚的に残すが操作無効） */
#input-area {
  position: fixed;
  bottom: var(--kb, 0px); /* キーボードが開いているときは、キーボードのすぐ上（js/chat.js の fitKeyboard） */
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
  background: #0d0830;
  border-top: 1.5px solid #4b1d9e;
  box-shadow: 0 0 16px rgba(107, 255, 128, 0.1);
}
#question {
  flex: 1;
  resize: none;
  border: 1.5px solid #2a1a5e;
  border-radius: 22px;
  padding: 9px 16px;
  font-size: 16px; /* 16px 未満だと iPhone が入力時に画面を拡大する */
  font-family: inherit;
  outline: none;
  line-height: 1.5;
  min-height: 44px;
  max-height: 120px;
  overflow-y: hidden; /* はみ出したときだけ JS で auto にする（16px にしたら上下の矢印が出ていたため） */
  word-break: break-word;
  background: #06061a;
  color: #e8e8ff;
  cursor: text;
  transition: border-color .15s, box-shadow .15s;
}
#question::placeholder { color: #3a2a6a; }
#question:focus {
  border-color: #6bff80;
  box-shadow: 0 0 8px rgba(107, 255, 128, 0.25);
}

#send-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: #24A59B; /* VIVRE色 */
  color: #06061a;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  transition: opacity .15s, box-shadow .15s;
  box-shadow: 0 0 10px rgba(36, 165, 155, 0.45);
}
#send-btn:hover { opacity: .85; box-shadow: 0 0 18px rgba(36, 165, 155, 0.75); }
#send-btn:active { opacity: .7; }
#send-btn .material-symbols-outlined { font-size: 1.2rem; }

@media (max-width: 480px) {
  header h1 { font-size: .97rem; }
  .bubble { font-size: .88rem; }
  .quick-btn { font-size: .82rem; padding: 6px 13px; }
}

/* ---- ハンバーガーボタン ---- */
#menu-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #e040e0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background .15s;
  filter: drop-shadow(0 0 4px #e040e0);
}
#menu-btn:hover { background: rgba(224, 64, 224, 0.15); }
#menu-btn .material-symbols-outlined { font-size: 1.6rem; }

/* ---- 設定オーバーレイ ---- */
#settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
}
#settings-overlay.open { display: block; }

/* ---- 設定パネル ---- */
#settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(300px, 85vw);
  background: #0d0830;
  border-left: 2px solid #e040e0;
  box-shadow: -4px 0 32px rgba(224, 64, 224, 0.4);
  z-index: 101;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top, 0));
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .25s ease;
}
#settings-panel.open {
  transform: translateX(0);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.settings-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #f0e8ff;
  letter-spacing: .04em;
}
#close-settings {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #9988cc;
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 6px;
  transition: color .15s;
}
#close-settings:hover { color: #e040e0; }
#close-settings .material-symbols-outlined { font-size: 1.4rem; }

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.settings-item-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .9rem;
  color: #e8e8ff;
}
.settings-item-label .material-symbols-outlined {
  font-size: 1.2rem;
  color: #6bff80;
}

.settings-note {
  font-size: .72rem;
  color: #6a5a9a;
  line-height: 1.5;
  margin-top: -12px;
}

.settings-item--link {
  justify-content: flex-start;
  gap: 8px;
  margin-top: 8px;
}
.settings-item--link .material-symbols-outlined {
  font-size: 1.2rem;
  color: #a78bfa;
}
.settings-link {
  font-size: .9rem;
  color: #c4b5fd;
  text-decoration: none;
  border-bottom: 1px solid #7c3aed55;
  padding-bottom: 1px;
  transition: color .2s, border-color .2s;
}
.settings-link:hover {
  color: #e9d5ff;
  border-color: #a78bfa;
}
.settings-note--admin {
  margin-top: -4px;
}

.settings-version {
  margin-top: auto;
  font-size: .68rem;
  color: #3a2a6a;
  letter-spacing: .06em;
  text-align: center;
  padding-top: 8px;
}
body.light-mode .settings-version {
  color: #d1d5db;
}

/* トグルスイッチ */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  border-radius: 13px;
  background: #2a1a5e;
  border: 1.5px solid #4b1d9e;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #9988cc;
  top: 2px;
  left: 2px;
  transition: transform .2s, background .2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: #6bff80;
  border-color: #6bff80;
}
.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(22px);
  background: #06061a;
}

/* ================================================================
   大きい文字モード
   ================================================================ */
body.large-text .bubble { font-size: 1.05rem; }
body.large-text .quick-btn { font-size: .95rem; padding: 8px 18px; }
body.large-text .bubble-text { font-size: 1.05rem; }
body.large-text .label { font-size: .75rem; }
body.large-text .spinner-wrap span { font-size: .9rem; }
body.large-text .timetable-task { font-size: .96rem; }
body.large-text .timetable-time { font-size: .84rem; }

@media (max-width: 480px) {
  body.large-text .bubble { font-size: 1rem; }
  body.large-text .quick-btn { font-size: .9rem; padding: 7px 15px; }
}

/* ================================================================
   ライトモード
   ================================================================ */
body.light-mode {
  background: #f0f4f8;
}

body.light-mode #chat {
  background: #f0f4f8;
}

body.light-mode header {
  background: #1a56db;
  color: #fff;
  border-bottom: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
body.light-mode header .material-symbols-outlined {
  color: #fff;
  filter: none;
}

body.light-mode #menu-btn {
  color: rgba(255,255,255,0.85);
  filter: none;
}
body.light-mode #menu-btn:hover { background: rgba(255,255,255,0.15); }

body.light-mode .bot-avatar {
  background: linear-gradient(135deg, #1648c0, #1a56db);
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}

body.light-mode .label {
  color: #6b7280;
  text-shadow: none;
}

body.light-mode .bubble.bot-bubble {
  background: #fff;
  color: #1f2937;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.10);
}

body.light-mode .bubble.user-bubble {
  background: #1a56db;
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}

body.light-mode .quick-btn {
  background: #fff;
  color: #1a56db;
  border-color: #1a56db;
  box-shadow: none;
}
body.light-mode .quick-btn:hover {
  background: #1a56db;
  color: #fff;
  box-shadow: none;
}

body.light-mode .return-btn {
  color: #1648c0;
  border-color: #1648c0;
  box-shadow: none;
}
body.light-mode .return-btn:hover {
  background: #1648c0;
  color: #fff;
  box-shadow: none;
}

body.light-mode .spinner {
  border-color: #d1d5db;
  border-top-color: #1a56db;
  box-shadow: none;
}
body.light-mode .spinner-wrap span { color: #6b7280; }


body.light-mode #settings-panel {
  background: #fff;
  border-left: 1px solid #e5e7eb;
  box-shadow: -4px 0 20px rgba(0,0,0,.1);
}
body.light-mode .settings-header h2 { color: #1f2937; }
body.light-mode #close-settings { color: #9ca3af; }
body.light-mode #close-settings:hover { color: #1a56db; }
body.light-mode .settings-item-label { color: #374151; }
body.light-mode .settings-item-label .material-symbols-outlined { color: #1a56db; }
body.light-mode .settings-note { color: #9ca3af; }
body.light-mode .settings-item--dark-only { display: none; }
body.light-mode .settings-item--link .material-symbols-outlined { color: #6d28d9; }
body.light-mode .settings-link { color: #4c1d95; border-color: #7c3aed55; }
body.light-mode .settings-link:hover { color: #7c3aed; border-color: #7c3aed; }
body.light-mode .toggle-slider {
  background: #e5e7eb;
  border-color: #d1d5db;
}
body.light-mode .toggle-slider::after { background: #9ca3af; }
body.light-mode .toggle-switch input:checked + .toggle-slider {
  background: #1a56db;
  border-color: #1a56db;
}
body.light-mode .toggle-switch input:checked + .toggle-slider::after {
  background: #fff;
}

body.light-mode #input-area {
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: none;
}
body.light-mode #question {
  background: #fff;
  color: #1f2937;
  border-color: #d1d5db;
}
body.light-mode #question::placeholder { color: #9ca3af; }
body.light-mode #question:focus {
  border-color: #1a56db;
  box-shadow: 0 0 6px rgba(26, 86, 219, 0.2);
}

body.light-mode #send-btn {
  background: #1a56db;
  color: #fff;
  box-shadow: none;
}
body.light-mode #send-btn:hover { opacity: .85; }

/* ---- 値引き計算ボタン（ヘッダー） ---- */
#discount-calc-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #e040e0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background .15s;
  filter: drop-shadow(0 0 4px #e040e0);
}
#discount-calc-btn:hover { background: rgba(224, 64, 224, 0.15); }
#discount-calc-btn .material-symbols-outlined { font-size: 1.6rem; }

body.light-mode #discount-calc-btn {
  color: rgba(255,255,255,0.85);
  filter: none;
}
body.light-mode #discount-calc-btn:hover { background: rgba(255,255,255,0.15); }

/* ---- 値引き計算オーバーレイ ---- */
#discount-calc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
}
#discount-calc-overlay.open { display: block; }

/* ---- 値引き計算パネル ---- */
#discount-calc-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(340px, 92vw);
  background: #0d0830;
  border-left: 2px solid #e040e0;
  box-shadow: -4px 0 32px rgba(224, 64, 224, 0.3);
  z-index: 201;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top, 0));
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: translateX(100%);
  transition: transform .25s ease;
  overflow-y: auto;
}
#discount-calc-panel.open { transform: translateX(0); }

body.light-mode #discount-calc-panel {
  background: #fff;
  border-left-color: #9333ea;
  box-shadow: -4px 0 32px rgba(147, 51, 234, 0.15);
}

/* ---- タイムテーブルボタン（ヘッダー） ---- */
#timetable-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #6bff80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background .15s;
  filter: drop-shadow(0 0 4px #6bff80);
}
#timetable-btn:hover { background: rgba(107, 255, 128, 0.15); }
#timetable-btn .material-symbols-outlined { font-size: 1.6rem; }

body.light-mode #timetable-btn {
  color: rgba(255,255,255,0.85);
  filter: none;
}
body.light-mode #timetable-btn:hover { background: rgba(255,255,255,0.15); }

/* ---- タイムテーブルオーバーレイ ---- */
#timetable-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
}
#timetable-overlay.open { display: block; }

/* ---- タイムテーブルパネル ---- */
#timetable-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(340px, 92vw);
  background: #0d0830;
  border-left: 2px solid #6bff80;
  box-shadow: -4px 0 32px rgba(107, 255, 128, 0.3);
  z-index: 201;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top, 0));
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: translateX(100%);
  transition: transform .25s ease;
  overflow-y: auto;
}
#timetable-panel.open { transform: translateX(0); }

.timetable-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #9988cc;
  font-size: .85rem;
}

.timetable-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timetable-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(107, 255, 128, 0.1);
}
.timetable-row:last-child { border-bottom: none; }

.timetable-time {
  font-size: .76rem;
  font-weight: 700;
  color: #6bff80;
  text-shadow: 0 0 6px rgba(107, 255, 128, 0.6);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 90px;
  padding-top: 2px;
  letter-spacing: .02em;
}

.timetable-task {
  font-size: .88rem;
  color: #e8e8ff;
  line-height: 1.5;
  padding-top: 1px;
}

.timetable-note {
  font-size: .72rem;
  color: #6a5a9a;
  line-height: 1.6;
  border-top: 1px solid rgba(107, 255, 128, 0.15);
  padding-top: 12px;
  margin-top: 4px;
}

/* タイムテーブルのライトモード */
body.light-mode #timetable-panel {
  background: #fff;
  border-left: 1px solid #e5e7eb;
  box-shadow: -4px 0 20px rgba(0,0,0,.1);
}
body.light-mode .timetable-time {
  color: #1a56db;
  text-shadow: none;
}
body.light-mode .timetable-row { border-bottom-color: #e5e7eb; }
body.light-mode .timetable-task { color: #1f2937; }
body.light-mode .timetable-note { color: #9ca3af; border-top-color: #e5e7eb; }
body.light-mode #timetable-panel .settings-header h2 { color: #1f2937; }
body.light-mode #close-timetable { color: #9ca3af; }
body.light-mode #close-timetable:hover { color: #1a56db; }

/* ---- チャット内スケジュール表示 ---- */
.schedule-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

.schedule-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0 8px 10px;
  border-left: 2px solid rgba(107, 255, 128, 0.4);
  margin-bottom: 8px;
}
.schedule-row:last-child { margin-bottom: 0; }

.schedule-time {
  font-size: .72rem;
  font-weight: 700;
  color: #6bff80;
  text-shadow: 0 0 5px rgba(107, 255, 128, 0.5);
  letter-spacing: .02em;
}

.schedule-task {
  font-size: .9rem;
  color: #e8e8ff;
  line-height: 1.55;
}

.schedule-task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.schedule-task-list li {
  font-size: .9rem;
  color: #e8e8ff;
  line-height: 1.55;
  padding-left: 1em;
  position: relative;
}
.schedule-task-list li::before {
  content: '・';
  position: absolute;
  left: 0;
  color: #6bff80;
}

body.light-mode .schedule-row       { border-left-color: #1a56db; }
body.light-mode .schedule-time      { color: #1a56db; text-shadow: none; }
body.light-mode .schedule-task      { color: #1f2937; }
body.light-mode .schedule-task-list li { color: #1f2937; }
body.light-mode .schedule-task-list li::before { color: #1a56db; }

/* ---- 日配品 値引き計算ウィジェット ---- */
.discount-calc {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: rgba(107, 255, 128, 0.05);
  border: 1px solid rgba(107, 255, 128, 0.3);
  border-radius: 12px;
  min-width: 0;
  overflow: hidden;
}

.calc-title {
  font-size: .78rem;
  font-weight: 700;
  color: #6bff80;
  text-shadow: 0 0 6px rgba(107, 255, 128, 0.6);
  letter-spacing: .04em;
}

.calc-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calc-label {
  font-size: .74rem;
  color: #9988cc;
}

.calc-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

.calc-input {
  background: #06061a;
  color: #e8e8ff;
  border: 1.5px solid #2a1a5e;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 16px; /* 16px 未満だと iPhone が入力時に画面を拡大する */
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.calc-input:focus {
  border-color: #6bff80;
  box-shadow: 0 0 6px rgba(107, 255, 128, 0.3);
}
.calc-input[type="date"] { appearance: none; -webkit-appearance: none; min-height: 2.4rem; }
.calc-input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.7); cursor: pointer; }
.calc-input-sm { width: 80px; flex-shrink: 0; }

.calc-unit {
  font-size: .82rem;
  color: #9988cc;
  white-space: nowrap;
}

.calc-exec-btn { align-self: flex-start; }

.calc-result {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.5;
}
.calc-result-discount {
  background: rgba(107, 255, 128, 0.1);
  color: #6bff80;
  border: 1px solid rgba(107, 255, 128, 0.4);
  text-shadow: 0 0 8px rgba(107, 255, 128, 0.5);
}
.calc-result-none {
  background: rgba(153, 136, 204, 0.08);
  color: #9988cc;
  border: 1px solid rgba(153, 136, 204, 0.3);
}
.calc-result-error {
  background: rgba(224, 64, 224, 0.08);
  color: #e040e0;
  border: 1px solid rgba(224, 64, 224, 0.3);
}

/* ---- キャラクターなしモード ---- */
.header-bot-avatar {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4b1d9e, #e040e0);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(224, 64, 224, 0.5);
}
.header-bot-avatar .material-symbols-outlined {
  font-size: 1.2rem;
  color: #fff;
  filter: none;
}
body.no-character .header-icon { display: none; }
body.no-character .header-bot-avatar { display: flex; }

.login-bot-avatar {
  display: none;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4b1d9e, #e040e0);
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px rgba(224, 64, 224, 0.4);
}
.login-bot-avatar .material-symbols-outlined {
  font-size: 2.4rem;
  color: #fff;
  filter: none;
}
body.no-character .login-icon { display: none; }
body.no-character .login-bot-avatar { display: flex; }

/* ---- ログイン画面 ---- */
#login-overlay, #maint-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: #06061a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#login-overlay[hidden], #maint-overlay[hidden] { display: none; }

#login-box, #maint-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 320px;
}

.login-icon {
  width: 96px;
  height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 0 14px #e040e0);
}

.login-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f0e8ff;
  letter-spacing: .03em;
}

.login-subtitle {
  font-size: .82rem;
  color: #9988cc;
  margin-top: -6px;
}

.login-input {
  width: 100%;
  background: #06061a;
  color: #e8e8ff;
  border: 1.5px solid #2a1a5e;
  border-radius: 22px;
  padding: 12px 18px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-input:focus {
  border-color: #6bff80;
  box-shadow: 0 0 8px rgba(107, 255, 128, 0.25);
}

.login-btn {
  width: 100%;
  background: linear-gradient(135deg, #4b1d9e, #e040e0);
  color: #fff;
  border: none;
  border-radius: 22px;
  padding: 12px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, box-shadow .15s;
  box-shadow: 0 0 16px rgba(224, 64, 224, 0.4);
}
.login-btn:hover { opacity: .85; box-shadow: 0 0 24px rgba(224, 64, 224, 0.6); }
.login-btn:active { opacity: .7; }
.login-btn:disabled { opacity: .5; cursor: not-allowed; }
#maint-box .login-icon, #maint-box .login-bot-avatar { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.maint-hop { animation: maint-hop .55s ease; }
@keyframes maint-hop {
  0%   { transform: translateY(0) rotate(0); }
  35%  { transform: translateY(-14px) rotate(-8deg); }
  65%  { transform: translateY(0) rotate(4deg); }
  80%  { transform: translateY(-4px) rotate(0); }
  100% { transform: translateY(0) rotate(0); }
}
@media (prefers-reduced-motion: reduce) { .maint-hop { animation: none; } }
#maint-check-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
#maint-check-btn .material-symbols-outlined { font-size: 20px; }

.login-subtitle { line-height: 1.6; text-align: center; }

.login-otp {
  text-align: center;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 1.3rem;
  letter-spacing: .25em;
  text-transform: uppercase;
}
.login-otp::placeholder { letter-spacing: .05em; font-size: .95rem; }

.login-note {
  font-size: .72rem;
  line-height: 1.6;
  color: #6a5a9a;
  text-align: center;
}
body.light-mode .login-note { color: #9ca3af; }

.login-error {
  font-size: .82rem;
  color: #e040e0;
  text-align: center;
}

/* ログアウトボタン */
.settings-link-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  color: #c4b5fd;
  font-family: inherit;
  padding: 0 0 1px;
  border-bottom: 1px solid #7c3aed55;
  transition: color .2s, border-color .2s;
}
.settings-link-btn:hover { color: #e9d5ff; border-color: #a78bfa; }

body.light-mode .settings-link-btn { color: #4c1d95; border-color: #7c3aed55; }
body.light-mode .settings-link-btn:hover { color: #7c3aed; border-color: #7c3aed; }

/* ライトモード - ログイン */
body.light-mode #login-overlay, body.light-mode #maint-overlay { background: #f0f4f8; }
body.light-mode .login-title { color: #1f2937; }
body.light-mode .login-subtitle { color: #6b7280; }
body.light-mode .login-input { background: #fff; color: #1f2937; border-color: #d1d5db; }
body.light-mode .login-input:focus { border-color: #1a56db; box-shadow: 0 0 6px rgba(26, 86, 219, 0.2); }
body.light-mode .login-btn { background: #1a56db; box-shadow: none; }
body.light-mode .login-error { color: #dc2626; }

/* ライトモード */
body.light-mode .discount-calc {
  background: #f0f9ff;
  border-color: #bfdbfe;
}
body.light-mode .calc-title {
  color: #1a56db;
  text-shadow: none;
}
body.light-mode .calc-label { color: #6b7280; }
body.light-mode .calc-unit  { color: #6b7280; }
body.light-mode .calc-input {
  background: #fff;
  color: #1f2937;
  border-color: #d1d5db;
}
body.light-mode .calc-input:focus {
  border-color: #1a56db;
  box-shadow: 0 0 6px rgba(26, 86, 219, 0.2);
}
body.light-mode .calc-input[type="date"]::-webkit-calendar-picker-indicator { filter: none; }
body.light-mode .calc-result-discount {
  background: #ecfdf5;
  color: #059669;
  border-color: #6ee7b7;
  text-shadow: none;
}
body.light-mode .calc-result-none {
  background: #f9fafb;
  color: #6b7280;
  border-color: #e5e7eb;
}
body.light-mode .calc-result-error {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* ---- マニュアル表示（Markdown） ---- */
.bot-row:has(.manual-bubble) {
  max-width: 94%;
  scroll-margin-top: 12px;
}
.bot-row:has(.manual-bubble) .bot-avatar { align-self: flex-start; }

.manual-title {
  font-weight: 700;
  color: #6bff80;
  text-shadow: 0 0 5px rgba(107, 255, 128, 0.5);
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(107, 255, 128, 0.3);
}

.md { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.md > * { margin: 0; }
.md h3, .md h4, .md h5, .md h6 {
  font-size: .95rem;
  color: #6bff80;
  margin-top: 6px;
}
.md h5, .md h6 { font-size: .88rem; color: #b8a8ff; }
.md ul, .md ol { padding-left: 1.3em; }
.md li + li { margin-top: 3px; }
.md li > ul, .md li > ol { margin-top: 3px; }
.md strong { color: #fff; background: rgba(224, 64, 224, 0.25); padding: 0 2px; border-radius: 3px; }
.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85em;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 4px;
  border-radius: 4px;
}
.md a { color: #6bff80; }
.md hr { border: none; border-top: 1px solid rgba(107, 255, 128, 0.25); width: 100%; }
.md blockquote {
  border-left: 3px solid #e040e0;
  padding: 4px 0 4px 10px;
  color: #c8c0f0;
}
.md-table-wrap { overflow-x: auto; max-width: 100%; }
.md table { border-collapse: collapse; font-size: .85rem; min-width: 100%; }
.md th, .md td {
  border: 1px solid rgba(107, 255, 128, 0.3);
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
}
.md th { background: rgba(107, 255, 128, 0.12); color: #6bff80; white-space: nowrap; }

body.large-text .md { font-size: 1.05rem; }
body.large-text .md table { font-size: .95rem; }

body.light-mode .manual-title { color: #1a56db; text-shadow: none; border-bottom-color: #dbe4f5; }
body.light-mode .md h3, body.light-mode .md h4 { color: #1a56db; }
body.light-mode .md h5, body.light-mode .md h6 { color: #4b5563; }
body.light-mode .md strong { color: #111827; background: #fef3c7; }
body.light-mode .md code { background: #f3f4f6; }
body.light-mode .md a { color: #1a56db; }
body.light-mode .md hr { border-top-color: #e5e7eb; }
body.light-mode .md blockquote { border-left-color: #1a56db; color: #4b5563; }
body.light-mode .md th, body.light-mode .md td { border-color: #d1d5db; }
body.light-mode .md th { background: #eef2ff; color: #1a56db; }

/* ===== 隠しコマンドの演出（js/secrets.js） ===== */
.secret-rain {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999; overflow: hidden;
}
.secret-rain span, .secret-rain i {
  position: absolute; top: -60px;
  animation-name: secret-fall; animation-timing-function: linear; animation-fill-mode: forwards;
}
.secret-confetti i { width: 8px; height: 14px; border-radius: 2px; opacity: .9; }
@keyframes secret-fall {
  to { transform: translateY(calc(100vh + 120px)) rotate(540deg); }
}

body.secret-party #app { animation: secret-hue 1.6s linear infinite; }
@keyframes secret-hue { to { filter: hue-rotate(360deg); } }

.secret-spin { animation: secret-spin-anim 1.1s cubic-bezier(.2, .8, .2, 1); }
@keyframes secret-spin-anim { to { transform: rotate(1080deg) scale(1); } }


body.secret-glitch #app { animation: secret-glitch .7s steps(6) 1; }
@keyframes secret-glitch {
  20% { transform: translate(-3px, 1px); filter: invert(1) hue-rotate(90deg); }
  40% { transform: translate(3px, -1px); filter: none; }
  60% { transform: translate(-2px, 2px); filter: invert(1); }
  80% { transform: translate(2px, 0); filter: none; }
}

@keyframes secret-pop { from { transform: scale(.6); opacity: 0; } }

/* カイルくん画像（背景透過）がライトモードの青い背景に埋もれないようにする */
body.light-mode .header-icon { filter: drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 4px rgba(255, 255, 255, .9)); }
body.light-mode .bot-avatar:has(.bot-avatar-img) { background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .18); }

/* ===== カイルくんとおしゃべり（js/talk.js） ===== */
#talk-bar {
  position: fixed;
  bottom: calc(var(--input-h, 70px) + var(--kb, 0px));
  left: 0; right: 0;
  z-index: 9;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 4px 12px;
  font-size: .72rem;
  color: #e8e8ff;
  background: linear-gradient(90deg, rgba(75, 29, 158, .85), rgba(36, 165, 155, .85));
}
#talk-bar[hidden] { display: none; }
#talk-bar button {
  border: 1px solid rgba(255, 255, 255, .6); background: transparent; color: #fff;
  border-radius: 99px; padding: 1px 10px; font: inherit; font-weight: 700; cursor: pointer;
}
body.talk-mode #ai-disclaimer { visibility: hidden; }
body.talk-mode #question { border-color: #24A59B; box-shadow: 0 0 8px rgba(36, 165, 155, .35); }
body.light-mode #talk-bar { background: linear-gradient(90deg, #1a56db, #24A59B); }
.talk-typing .bubble-text { animation: talk-blink 1s ease-in-out infinite; }
@keyframes talk-blink { 50% { opacity: .3; } }

/* ネタ画像（js/secrets.js） */
.secret-meme {
  position: fixed; inset: 0; z-index: 10001;
  background: rgba(0, 0, 0, .88);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 16px;
  animation: secret-pop .35s cubic-bezier(.2, 1.4, .4, 1);
}
.secret-meme img, .secret-meme video {
  max-width: 100%; max-height: calc(100dvh - 80px);
  border-radius: 12px; box-shadow: 0 0 30px rgba(224, 64, 224, .45);
}
.secret-meme-close { color: rgba(255, 255, 255, .6); font-size: .75rem; }
.meme-bubble { padding: 8px; }
.meme-media { display: block; width: 100%; max-width: 260px; border-radius: 12px; cursor: zoom-in; }
video.meme-media { cursor: default; }

/* 攻略した隠し要素（設定画面） */
.secret-log {
  border: 1px solid #2a1a5e; border-radius: 12px; padding: 12px 14px;
  background: rgba(255, 255, 255, .03);
  display: flex; flex-direction: column; gap: 8px;
}
.secret-log.complete { border-color: #e8c45a; box-shadow: 0 0 14px rgba(232, 196, 90, .35); }
.secret-log-head { display: flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 700; color: #e8e8ff; }
.secret-log-head .material-symbols-outlined { font-size: 1.1rem; color: #9988cc; }
.secret-log-count { margin-left: auto; font-size: .8rem; color: #9988cc; font-variant-numeric: tabular-nums; }
.secret-log.complete .secret-log-count { color: #ffe08a; }
.secret-log-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.secret-log-list li {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: .78rem; color: #6a5a9a; padding: 5px 8px; border-radius: 6px; background: rgba(0, 0, 0, .2);
}
.secret-log-list li.got { color: #e8e8ff; }
.secret-log-list li.got .secret-log-name::before {
  content: 'check';
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-size: 1.1em;
  vertical-align: -.2em;
  margin-right: 2px;
  color: #24A59B;
}
.secret-log-when { font-size: .68rem; color: #9988cc; white-space: nowrap; }
.secret-log-done {
  white-space: pre-line; font-size: .85rem; font-weight: 700; color: #ffe08a; text-align: center; line-height: 1.7;
  margin-top: -12px; padding: 12px; border: 1px solid #e8c45a; border-radius: 12px;
  box-shadow: 0 0 14px rgba(232, 196, 90, .35); background: rgba(232, 196, 90, .06);
}
body.light-mode .secret-log-done { border-color: #f59e0b; background: #fffbeb; box-shadow: none; }
body.light-mode .secret-log { border-color: #e5e7eb; background: #f9fafb; }
body.light-mode .secret-log-head { color: #1f2937; }
body.light-mode .secret-log-list li { background: #fff; color: #9ca3af; }
body.light-mode .secret-log-list li.got { color: #1f2937; }
body.light-mode .secret-log-done { color: #b45309; }


/* ダブルタップで画面が拡大しないようにする（ピンチでの拡大はできる）。
   カイルくんのアイコンを連打したときなどに拡大されてしまうのを防ぐ */
*, *::before, *::after { touch-action: manipulation; }

/* ===== 右下のカイルくん（js/agent.js：Microsoft Agent のアニメを再生） ===== */
#kairu-agent {
  position: fixed;
  right: 4px;
  bottom: calc(var(--input-h, 70px) + var(--kb, 0px) + 24px);
  width: 132px;
  z-index: 9;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none; /* 長押しで「画像を保存」などのメニューを出さない */
  -webkit-user-select: none;
  user-select: none;
  will-change: transform;
  filter: drop-shadow(0 0 8px rgba(80, 170, 255, .35));
}
#kairu-agent canvas { display: block; width: 100%; height: auto; }
/* 泳いでいる間はタップを受け付けない（下のボタンを押せるように） */
#kairu-agent.swimming { pointer-events: none; }
body.no-character #kairu-agent { display: none; }
/* 最後のメッセージがカイルくんの後ろに隠れないよう、会話欄の下に余白をとる */
#chat { padding-bottom: 108px; }
body.no-character #chat { padding-bottom: 8px; }
.kairu-bubble {
  position: fixed; z-index: 8; pointer-events: none;
  border-radius: 50%;
  border: 1.5px solid rgba(180, 225, 255, .8);
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, .7), rgba(150, 210, 255, .15) 60%);
  animation: kairu-bubble 1.6s ease-out forwards;
}
@keyframes kairu-bubble {
  from { opacity: .9; transform: translateY(0) scale(.6); }
  to   { opacity: 0;  transform: translateY(-60px) scale(1.1); }
}

/* 右下のカイルくんの吹き出し（当時の Office アシスタント風） */
#kairu-balloon {
  position: fixed;
  right: 10px;
  bottom: calc(var(--input-h, 70px) + var(--kb, 0px) + 24px + 108px);
  z-index: 11;
  width: max-content;
  min-width: 120px;
  max-width: min(270px, calc(100vw - 24px));
  padding: 10px 13px;
  background: #ffffe1;
  color: #000;
  border: 1px solid #000;
  border-radius: 12px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .35);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
#kairu-balloon[hidden] { display: none; }
.kairu-balloon-text { max-height: 40vh; overflow-y: auto; }
/* しっぽ（右下のカイルくんの方へ） */
#kairu-balloon::after {
  content: '';
  position: absolute;
  right: 74px; /* カイルくんの頭（左寄り）を指す */
  bottom: -8px;
  width: 14px; height: 14px;
  background: #ffffe1;
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
  transform: rotate(45deg);
}
.kairu-balloon-pop { animation: kairu-balloon-pop .18s ease-out; }
@keyframes kairu-balloon-pop { from { transform: scale(.85); opacity: 0; } }
.kairu-balloon-wait { animation: talk-blink 1s ease-in-out infinite; }
body.no-character #kairu-balloon { display: none; }

/* 吹き出しの値引き判定（右上の電卓ボタン）。薄い黄色の吹き出しに合わせた明るい配色 */
.kairu-balloon-form { white-space: normal; }
.kairu-balloon-form[hidden] { display: none; }
.balloon-calc { display: flex; flex-direction: column; gap: 8px; width: min(240px, calc(100vw - 50px)); }
.balloon-calc-ask { margin: 0; }
.balloon-calc-row { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
#kairu-balloon .calc-input {
  background: #fff;
  color: #000;
  border: 1px solid #7a7a7a;
  border-radius: 4px;
  padding: 5px 8px;
}
#kairu-balloon .calc-input:focus { border-color: #000; box-shadow: none; }
#kairu-balloon .calc-input[type="date"]::-webkit-calendar-picker-indicator { filter: none; }
#kairu-balloon .calc-result { padding: 6px 8px; font-size: 13px; border-radius: 4px; text-shadow: none; }
#kairu-balloon .calc-result-discount { background: #e3f6ec; color: #0b6b3a; border: 1px solid #0b6b3a; }
#kairu-balloon .calc-result-none     { background: #f0f0f0; color: #333;    border: 1px solid #999; }
#kairu-balloon .calc-result-error    { background: #fde8e8; color: #b00020; border: 1px solid #b00020; }
.balloon-calc-btns { display: flex; gap: 8px; justify-content: flex-end; }
/* 当時の Windows のボタン風 */
.balloon-btn {
  font: inherit;
  font-size: 13px;
  padding: 4px 12px;
  color: #000;
  background: #ece9d8;
  border: 1px solid #000;
  border-radius: 3px;
  box-shadow: inset -1px -1px 0 #808080, inset 1px 1px 0 #fff;
  cursor: pointer;
}
.balloon-btn:active { box-shadow: inset 1px 1px 0 #808080; }
.balloon-btn-main { font-weight: 700; }

/* Material Symbols のアイコン（絵文字のかわり） */
.bubble-icons { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 4px; color: #6bff80; }
.bubble-icons .material-symbols-outlined { font-size: 1.25rem; }
.bubble-icons-text { font-weight: 800; letter-spacing: .1em; margin-left: 4px; line-height: 1.25rem; }
body.light-mode .bubble-icons { color: #24A59B; }
.secret-rain .material-symbols-outlined { color: #7dd3fc; text-shadow: 0 0 8px rgba(125, 211, 252, .6); }
.secret-log-cup { font-size: 1.3em; vertical-align: -.25em; margin-right: 4px; }
#talk-bar .material-symbols-outlined { font-size: 1.1em; vertical-align: -.2em; margin-right: 4px; }
.mark-star { color: #fbbf24; font-size: 1.15em; vertical-align: -.2em; margin-right: 2px; font-variation-settings: 'FILL' 1; }
.mark-now {
  display: inline-flex; align-items: center; gap: 2px;
  margin-left: 6px; padding: 0 8px 0 4px;
  border-radius: 999px;
  background: #24A59B; color: #fff;
  font-size: .8em; font-weight: 700; vertical-align: .1em;
}
.mark-now .material-symbols-outlined { font-size: 1.1em; }
