:root {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* =========================================================
   Theme system (Mode -> Space)
   - theme-free : Cafe table
   - theme-wall : Notebook
   - theme-dusk : Closing (sunset)
   ========================================================= */

body {
  margin: 0;
  transition: background 250ms ease, color 250ms ease;
}

/* ---------- Free talk (Cafe table) ---------- */
body.theme-free {
  /* 単色だと気づきにくいので、カフェっぽい柔らかいグラデに */
  background: linear-gradient(180deg, #f4efe8 0%, #efe6dc 100%);
  color: #1f2328;
}

/* ---------- Wall (Notebook) ---------- */
body.theme-wall {
  background: #f5f1e8; /* paper */
  color: #1f2328;
}

/* ---------- Dusk (Closing) ---------- */
body.theme-dusk {
  background: linear-gradient(180deg, #fff1e3 0%, #f3e6ff 45%, #dfefff 100%);
  color: #1f2328;
}

/* App panel (glass on cafe / plain on notebook) */
.app {
  /* //***変更箇所**** ここから：Window幅に連動させる */
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  /* //***変更箇所**** ここまで */
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* App panel */
/* heme-free では app を透明にして body 背景を活かす */
body.theme-free .app {
  background: transparent;           /* ← ここが重要 */
  backdrop-filter: none;
}

/* dusk は演出なので少しガラス感を残す */
body.theme-dusk .app {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(6px);
}

/* wall は紙っぽく軽く */
body.theme-wall .app {
  background: rgba(255, 255, 255, 0.35);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
  /* //***変更箇所**** ここから */
  width: 100%;
  box-sizing: border-box;
  /* //***変更箇所**** ここまで */
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/*：theme-free でヘッダーをカード化して読みやすさ確保 */
body.theme-free .header,
body.theme-wall .header,
body.theme-dusk .header {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(4px);
}

.chat {
  padding: 16px;
  overflow: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Notebook lines only in wall mode */
/* ：罫線を見える濃さに */
body.theme-wall .chat {
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 22px,
      rgba(0, 0, 0, 0.085) 23px,   /* 罫線を濃く */
      rgba(0, 0, 0, 0.085) 24px
    );
}

 /* ：theme-free の chat をカード化 */
body.theme-free .chat,
body.theme-dusk .chat {
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(3px);
}

/* Bubbles */
.bubble {
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 14px;
  white-space: pre-wrap;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}
.ai { align-self: flex-start; background: rgba(255, 255, 255, 0.72); }
.user { align-self: flex-end; background: rgba(70, 130, 180, 0.12); }

.composer {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.35);
}

/* //***変更箇所**** ここから：range以外の入力欄だけに通常入力スタイルを適用 */
input:not([type="range"]),
textarea {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.72);
  color: #1f2328;
  font-family: inherit;
  font-size: 14px;
}

textarea {
  min-height: 44px;
  max-height: 140px;
  resize: vertical;
  line-height: 1.5;
}

input:not([type="range"]):focus,
textarea:focus {
  outline: none;
  border-color: rgba(70, 130, 180, 0.55);
}
/* //***変更箇所**** ここまで */

.btn {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.65);
  color: #1f2328;
  cursor: pointer;
}
.btn:hover { background: rgba(255, 255, 255, 0.8); }
.ghost { background: transparent; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  padding: 18px;
  /* //***変更箇所**** ここから：headerのz-index引き上げでモーダルが埋もれないようにする */
  z-index: 10;
  /* //***変更箇所**** ここまで */
}
.modal.hidden { display: none; }

.modalCard {
  width: min(560px, 100%);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 16px;
  padding: 16px;
}
.modalActions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.closing { opacity: 0.9; }

/* Gate */
.gate {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 10;
}
.gateCard {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 16px;
  padding: 20px;
  width: min(360px, 90%);
  text-align: center;
}
.error { color: #c62828; font-size: 12px; margin-top: 8px; }
.hidden { display: none; }

/* 壁打ち（wall5）専用のバブル無し表示 */

body.theme-wall .bubble { display: none; } /* 念のため（壁打ちでは bubble を使わない想定） */

.wallRow{
  max-width: 86%;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* AI：左寄せ + 左ライン */
.wallRow.ai{
  align-self: flex-start;
  margin-right: auto;
  border-left: 4px solid rgba(70, 130, 180, 0.45);
  background: rgba(255,255,255,0.38);
}

/* User：右寄せ + 右ライン */
.wallRow.user{
  align-self: flex-end;
  margin-left: auto;
  grid-template-columns: 1fr auto; /* ラベルを右に寄せる */
  border-right: 4px solid rgba(70, 130, 180, 0.65);
  background: rgba(70,130,180,0.10);
}

/* ラベル（チップ） */
.wallLabel{
  font-size: 11px;
  opacity: 0.75;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.55);
  height: fit-content;
}

.wallRow.user .wallLabel{
  justify-self: end;
}

/* 本文 */
.wallText{
  font-size: 14px;
}

/* //***変更箇所**** ここから：壁打ち時間設定・回答タイマー・まとめるボタン */
.wallDurationBox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

/* //***変更箇所**** ここから：壁打ちAI返答内の回答目安 */
.wallAnswerTimer {
  margin-top: 8px;
  text-align: right;
  font-size: 12px;
  opacity: 0.7;
}

.wallAnswerTimer.isOver {
  opacity: 1;
  font-weight: 700;
}
/* //***変更箇所**** ここまで */

.hidden {
  display: none;
}

/* //***変更箇所**** ここから：画像表示に近いヘッダー配置 */
.header {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 32px 40px 24px;
  /* //***変更箇所**** ここから：headerのbackdrop-filterが独自の重なり文脈を作り、
     z-index指定のドロップダウンが.chat（同じくbackdrop-filter持ち）の下に潜ってしまうため明示的に上げる */
  position: relative;
  z-index: 5;
  /* //***変更箇所**** ここまで */
}

.headerTop {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.headerTitleArea h1 {
  margin: 0;
  font-size: clamp(42px, 5vw, 64px);
  line-height: 1.05;
  font-weight: 800;
}

.headerTitleArea .sub {
  margin: 20px 0 0;
  font-size: 1.15rem;
}

.mode {
  display: flex;
  gap: 12px;
  align-items: center;
}

.mode .chip {
  min-width: 140px;
  padding: 14px 22px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.75);
}

.mode .chip.active {
  background: #1677ff;
  color: #fff;
  border-color: #1677ff;
}

.modeOption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.modeCaption {
  font-size: 0.78rem;
  color: var(--muted, #8a8a8a);
  text-align: center;
}

.headerBottom {
  display: flex;
  align-items: center;
  gap: 32px;
  min-height: 64px;
}

.wallTimerToggleBox {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.wallTimerToggleLabel {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
}

.wallTimerHint {
  font-size: 0.82rem;
  color: var(--muted, #8a8a8a);
}

.wallDurationBox {
  display: flex;
  align-items: center;
  gap: 14px;
}

.wallDurationBox label {
  white-space: nowrap;
}

/* //***変更箇所**** ここから：range専用に完全分離 */
#wallMinutesInput {
  display: block;
  width: clamp(140px, 18vw, 260px);
  min-width: 140px;
  height: 28px;
  flex: 0 0 auto;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  accent-color: #1677ff;
  pointer-events: auto;
}
/* //***変更箇所**** ここまで */

#wallMinutesValue {
  min-width: 42px;
  font-size: 1.1rem;
}

.wallTimerBox {
  display: flex;
  align-items: center;
  gap: 16px;
}

.timerLabel {
  white-space: nowrap;
}

#timerText {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.wallTimerBox .progress {
  width: 220px;
}

.sessionEndBtn {
  margin-left: auto;
  min-width: 180px;
  padding: 14px 22px;
  border-radius: 16px;
}
/* //***変更箇所**** ここまで */

/* //***変更箇所**** ここから：hiddenが後続のdisplay:flexに負けないようにする */
.hidden,
.wallDurationBox.hidden,
.wallTimerBox.hidden,
#summarizeBtn.hidden {
  display: none !important;
}
/* //***変更箇所**** ここまで */

/* //***変更箇所**** ここから：整理&GO！でも画面幅いっぱいに広げる */
body.theme-free .app,
body.theme-wall .app,
body.theme-dusk .app {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

body.theme-free .header,
body.theme-wall .header,
body.theme-dusk .header {
  width: 100%;
  box-sizing: border-box;
}

.headerTop,
.headerBottom {
  width: 100%;
  box-sizing: border-box;
}
/* //***変更箇所**** ここまで */

/* //***変更箇所**** ここから：時間UI左・終了ボタン右に固定 */
.headerBottom {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}

.wallControls {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

.sessionEndBtn {
  margin-left: auto;
  flex-shrink: 0;
}

.wallTimerBox .progress {
  width: clamp(120px, 18vw, 260px);
}
/* //***変更箇所**** ここまで */

/* //***変更箇所**** ここから：マイページUI */

/* ヘッダー右側ボタン群 */
.headerActions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.aboutBtn,
.myPageBtn,
.sessionEndBtn {
  min-width: 140px;
  padding: 14px 18px;
  border-radius: 16px;
}

/* マイページ本体 */
.myPageCard {
  width: min(920px, 100%);
  max-height: min(82vh, 760px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.myPageHeader {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.myPageHeader h2 {
  margin: 0;
}

.myPageHeader p {
  margin: 6px 0 0;
  opacity: 0.72;
  font-size: 14px;
}

.myPageGrid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  min-height: 0;
  padding-top: 16px;
}

.myPageMenu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.myPageMenuItem {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  background: rgba(255, 255, 255, 0.55);
  color: #1f2328;
  cursor: pointer;
  font-family: inherit;
}

.myPageMenuItem:hover {
  background: rgba(255, 255, 255, 0.78);
}

.myPageMenuItem.active {
  background: #1677ff;
  color: #fff;
  border-color: #1677ff;
}

.myPageContent {
  min-width: 0;
  overflow: auto;
  padding-right: 6px;
}

.myPagePanel {
  display: none;
  line-height: 1.75;
  font-size: 14px;
}

.myPagePanel.active {
  display: block;
}

.myPagePanel h3 {
  margin: 0 0 16px;
  font-size: 1.35rem;
}

.myPagePanel h4 {
  margin: 20px 0 6px;
  font-size: 1rem;
}

.myPagePanel p {
  margin: 0 0 10px;
}

/* //***変更箇所**** ここから：話し方タイプ（ペルソナ）選択（ヘッダーのmybo！アイコン→プルダウン） */
.personaPickerBox {
  position: relative;
}

.personaPickerBtn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.65);
  color: #1f2328;
  cursor: pointer;
  font-family: inherit;
}

.personaPickerBtn:hover {
  background: rgba(255, 255, 255, 0.85);
}

.personaPickerIcon {
  font-size: 1.3rem;
  line-height: 1;
}

.personaPickerLabel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.3;
}

.personaPickerCaption {
  font-size: 0.7rem;
  opacity: 0.65;
}

.personaPickerChevron {
  opacity: 0.5;
  font-size: 0.8rem;
}

.personaDropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  width: min(320px, 84vw);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.personaOption {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: #1f2328;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.personaOption:hover {
  background: rgba(0, 0, 0, 0.05);
}

.personaOption.active {
  border-color: #1677ff;
  background: rgba(22, 119, 255, 0.10);
}

.personaOptionText {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.personaIcon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.personaName {
  font-weight: 700;
  font-size: 0.86rem;
}

.personaDesc {
  font-size: 0.78rem;
  opacity: 0.72;
  line-height: 1.45;
}
/* //***変更箇所**** ここまで */

.contactPlaceholder {
  margin-top: 16px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(70, 130, 180, 0.10);
  border: 1px solid rgba(70, 130, 180, 0.18);
}

/* 既存の sessionEndBtn 指定を上書きして、Windows幅でも崩れにくくする */
.sessionEndBtn {
  margin-left: 0;
  flex-shrink: 0;
}

/* タブレット・狭めのPC */
@media (max-width: 820px) {
  .headerBottom {
    align-items: stretch;
  }

  .headerActions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .aboutBtn,
  .myPageBtn,
  .sessionEndBtn {
    min-width: 132px;
  }

  .myPageGrid {
    grid-template-columns: 1fr;
  }

  .myPageMenu {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .myPageMenuItem {
    text-align: center;
  }
}

/* スマホ */
@media (max-width: 560px) {
  .header {
    padding: 22px 16px 18px;
    gap: 20px;
  }

  .headerTop {
    flex-direction: column;
    align-items: stretch;
  }

  .mode {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .mode .chip {
    min-width: 0;
    width: 100%;
    padding: 12px 10px;
  }

  .headerBottom {
    flex-direction: column;
    gap: 16px;
  }

  .wallControls {
    width: 100%;
    gap: 16px;
  }

  .wallDurationBox,
  .wallTimerBox {
    width: 100%;
    justify-content: space-between;
  }

  .wallDurationBox input[type="range"],
  .wallTimerBox .progress {
    width: min(48vw, 220px);
  }

  .headerActions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
  }

  .aboutBtn,
  .myPageBtn,
  .sessionEndBtn {
    width: 100%;
    min-width: 0;
  }

  .headerActionItem {
    width: 100%;
  }

  .myPageCard {
    max-height: 86vh;
  }

  .myPageHeader {
    flex-direction: column;
  }

  .myPageCloseBtn {
    width: 100%;
  }

  .myPageMenu {
    grid-template-columns: 1fr;
  }
}
/* //***変更箇所**** ここまで */

/* //***変更箇所**** ここから：ヘッダー下段の重なりを防止してスライダーを操作可能にする */
.headerBottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  width: 100%;
  box-sizing: border-box;
}

.wallControls {
  grid-column: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}

.headerActions {
  grid-column: 2;
  margin-left: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: end;
  position: relative;
  z-index: 1;
}

#wallMinutesInput {
  position: relative;
  z-index: 3;
  pointer-events: auto;
  user-select: none;
}

.aboutBtn,
.myPageBtn,
.sessionEndBtn {
  user-select: none;
}

/* //***変更箇所**** ここから：「今日を閉じる」ボタンに説明キャプションを追加 */
.headerActionItem {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.headerActionCaption {
  font-size: 0.78rem;
  color: var(--muted, #8a8a8a);
  text-align: center;
  white-space: nowrap;
}
/* //***変更箇所**** ここまで */

/* 狭い画面では上下に分けて、絶対に重ならないようにする */
@media (max-width: 820px) {
  .headerBottom {
    grid-template-columns: 1fr;
  }

  .wallControls {
    grid-column: 1;
    width: 100%;
  }

  .headerActions {
    grid-column: 1;
    width: 100%;
    justify-content: flex-end;
  }
}

@media (max-width: 560px) {
  .headerActions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
  }
}
/* //***変更箇所**** ここまで */

/* //***変更箇所**** ここから：お問い合わせフォーム */

.contactForm {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 720px;
}

.contactField {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.contactField span {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.82;
}

.contactField input,
.contactField textarea,
.contactField select {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.72);
  color: #1f2328;
  font-family: inherit;
  font-size: 14px;
}

.contactField textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.6;
}

.contactField input:focus,
.contactField textarea:focus,
.contactField select:focus {
  outline: none;
  border-color: rgba(70, 130, 180, 0.55);
}

.contactNote {
  margin: 0;
  font-size: 12px;
  opacity: 0.72;
}

.contactActions {
  display: flex;
  justify-content: flex-end;
}

.contactStatus {
  min-height: 1.5em;
  margin: 0;
  font-size: 13px;
}

/* //***変更箇所**** ここから：送信結果を見落とさないよう枠付きで強調表示 */
.contactStatus:not(:empty) {
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  border: 1px solid transparent;
}

.contactStatus.sending {
  color: #4b5563;
  background: rgba(75, 85, 99, 0.08);
  border-color: rgba(75, 85, 99, 0.18);
}

.contactStatus.success {
  color: #1b7f3a;
  background: rgba(27, 127, 58, 0.10);
  border-color: rgba(27, 127, 58, 0.25);
}

.contactStatus.error {
  color: #c62828;
  background: rgba(198, 40, 40, 0.10);
  border-color: rgba(198, 40, 40, 0.25);
}

.contactStatus.flash {
  animation: contactStatusFlash 0.6s ease;
}

@keyframes contactStatusFlash {
  0% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
/* //***変更箇所**** ここまで */

@media (max-width: 560px) {
  .contactActions {
    justify-content: stretch;
  }

  .contactActions .btn {
    width: 100%;
  }
}
/* //***変更箇所**** ここまで */