/**
 * 相談投稿ページ（/post/thread）— html-chech/thread-post.html 準拠
 */

/* ===================================================================
   Hero — full-width video background, text pinned to bottom
   =================================================================== */
.thread-post-hero {
  position: relative;
  --_hero-extra-h: calc(7.5rem + 3.75rem - 20pt);
  --_hero-video-trim-y: calc(80px + 10pt);
  min-height: calc(22rem + var(--_hero-extra-h) - 100pt + 100px);
  overflow: hidden;
  background: var(--color-accent-2);
}

@media (min-width: 769px) {
  .thread-post-hero {
    --_hero-video-trim-y: calc(80px + 10pt + 50px);
    /* +50px 相当から PC のみ 30px 縮小（下側がトリミングされる） */
    min-height: calc(22rem + var(--_hero-extra-h) - 100pt + 50px - 30px);
  }
}

@media (max-width: 768px) {
  .thread-post-hero {
    min-height: calc(22rem + var(--_hero-extra-h) - 100pt);
  }
}

.thread-post-hero__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--color-accent-2);
  pointer-events: none;
}

.thread-post-hero__video {
  position: absolute;
  left: 0;
  width: 100%;
  height: calc(100% + var(--_hero-video-trim-y));
  top: calc(-1 * var(--_hero-video-trim-y));
  object-fit: cover;
  object-position: center 15%;
}

@media (max-width: 768px) {
  .thread-post-hero__video {
    object-position: center 12%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .thread-post-hero__video {
    display: none;
  }
}

.thread-post-hero__overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--color-hero-overlay);
  pointer-events: none;
}

.thread-post-hero__stack {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-top: 0;
  padding-bottom: var(--space-8);
  box-sizing: border-box;
}

@media (max-width: 900px) {
  .thread-post-hero__stack {
    padding-bottom: var(--space-6);
  }
}

.thread-post-hero__title {
  margin: 0 0 var(--space-3);
  width: 100%;
  max-width: 100%;
  font-size: clamp(var(--font-size-2xl), 2.5vw, 2.125rem);
  font-weight: 900;
  line-height: 1.3;
  color: var(--color-base-1);
  letter-spacing: 0.04em;
  text-align: center;
}

.thread-post-hero__bottom {
  margin-top: 0;
  width: 100%;
  padding-top: 0;
}

/* ===================================================================
   Anonymous toggle (switch UI)
   =================================================================== */
.thread-post-anon {
  margin-bottom: var(--space-6);
  padding: var(--space-4) var(--space-6);
  background: var(--color-base-1);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
}

.thread-post-hero__stack .thread-post-anon {
  max-width: 760px;
  margin-inline: auto;
  margin-bottom: 0;
  box-shadow: var(--shadow-figma-card);
  background: color-mix(in srgb, var(--color-base-1) 75%, transparent);
}

.thread-post-anon__label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}

.thread-post-anon__checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.thread-post-anon__switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  transition: background var(--transition-base);
}

.thread-post-anon__switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--color-base-1);
  border-radius: var(--radius-full);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform var(--transition-base);
}

.thread-post-anon__checkbox:checked + .thread-post-anon__switch {
  background: var(--color-main);
}

.thread-post-anon__checkbox:checked + .thread-post-anon__switch::after {
  transform: translateX(20px);
}

.thread-post-anon__checkbox:focus-visible + .thread-post-anon__switch {
  outline: 2px solid var(--color-main);
  outline-offset: 2px;
}

.thread-post-anon__text {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--color-text-primary);
}

.thread-post-anon__hint {
  margin: var(--space-2) 0 0;
  padding-left: calc(44px + var(--space-3));
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* ===================================================================
   Chat section — gray bg, centered 760px container
   =================================================================== */
.thread-post-chat {
  background: var(--color-base-2);
  padding: var(--space-8) var(--space-4) var(--space-12);
}

.thread-post-chat__inner {
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
}

/* API placeholder */
.thread-post-chat__placeholder {
  background: var(--color-base-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
}

.thread-post-chat__placeholder .dify-embed-placeholder__title {
  color: var(--color-text-primary);
}

/* ===================================================================
   Chat area — NO card wrapper; messages stack in a flex column
   =================================================================== */
.thread-post-page .thread-post-chat__area {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

/* Log (scrollable messages region) */
.thread-post-page .thread-post-chat__log {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* ===================================================================
   Chat message row
   =================================================================== */
.thread-post-chat__msg {
  display: flex;
  gap: var(--space-3);
  max-width: 100%;
}

.thread-post-chat__msg--user {
  flex-direction: row-reverse;
}

/* Avatar */
.thread-post-chat__avatar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.thread-post-chat__avatar--placeholder {
  width: 50px;
  min-height: 50px;
  border-radius: var(--radius-full);
  background: var(--color-base-2);
}

.thread-post-chat__avatar-img {
  display: block;
  width: 50px;
  height: 50px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--color-border-light);
}

.thread-post-chat__avatar-img--ai {
  border-color: color-mix(in srgb, var(--color-main) 22%, var(--color-border-light));
}

/* 匿名ON時・チャット内ユーザー発言の名無しアイコン */
.thread-post-page .thread-post-chat__avatar-img--anonymous {
  border-color: var(--color-border);
  object-fit: cover;
  background: var(--color-base-2);
}

/* ===================================================================
   Bubble (reuses .dify-chat__bubble for app.js compatibility)
   =================================================================== */
.thread-post-page .dify-chat__bubble {
  flex: 0 1 auto;
  max-width: 85%;
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  line-height: 1.7;
  color: var(--color-text-primary);
  word-break: break-word;
}

.thread-post-page .thread-post-chat__msg--assistant .dify-chat__bubble {
  background: var(--color-base-1);
  border: 1px solid var(--color-border-light);
  border-top-left-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
}

.thread-post-page .thread-post-chat__msg--user .dify-chat__bubble {
  background: var(--color-main);
  color: var(--color-base-1);
  border-top-right-radius: var(--radius-sm);
}

.thread-post-page .dify-chat__bubble p {
  margin: 0 0 var(--space-3);
}

.thread-post-page .dify-chat__bubble p:last-child {
  margin-bottom: 0;
}

.thread-post-page .dify-chat__bubble--rich {
  white-space: normal;
}

/* Hint note (e.g. "※目安：300字〜400字") */
.thread-post-chat__hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

/* Horizontal rule inside bubble */
.thread-post-page .dify-chat__rule {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-3) 0;
}

.thread-post-page .dify-chat__strong {
  font-weight: 700;
}

.thread-post-page .dify-chat__heading {
  display: inline-block;
  margin-top: var(--space-2);
}

/* ===================================================================
   Tables inside bubble (Q-table, summary)
   =================================================================== */
.thread-post-page .dify-chat__qtable,
.thread-post-page .dify-chat__summary {
  table-layout: fixed;
}

.thread-post-page .dify-chat__qtable {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-2) 0 var(--space-3);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-base);
}

.thread-post-page .dify-chat__qtable th,
.thread-post-page .dify-chat__summary th {
  border: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-3);
  vertical-align: top;
  font-weight: 700;
  text-align: left;
  background: var(--color-base-2);
  color: var(--color-text-primary);
}

.thread-post-page .dify-chat__qtable td {
  border: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-3);
  vertical-align: top;
}

.thread-post-page .dify-chat__qtable-case {
  font-weight: 700;
  width: 25%;
  color: var(--color-text-primary);
}

.thread-post-page .dify-chat__qtable-text {
  word-break: break-word;
  color: var(--color-text-primary);
}

.thread-post-page .dify-chat__summary {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-2) 0 var(--space-3);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-base);
  /* table-layout: fixed は上部の共通ルールで適用済み */
}

.thread-post-page .dify-chat__summary td {
  border: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-3);
  vertical-align: top;
}

.thread-post-page .dify-chat__summary-label {
  font-weight: 700;
  width: 25%;
  word-break: break-word;
  color: var(--color-text-primary);
}

.thread-post-page .dify-chat__summary-value {
  word-break: break-word;
  color: var(--color-text-primary);
}

.thread-post-page .dify-chat__summary-value .dify-chat__cell-rich {
  display: block;
  word-break: break-word;
}

.thread-post-page .dify-chat__summary--from-html .dify-chat__summary-value {
  white-space: pre-wrap;
}

/* ===================================================================
   Choice buttons — left-aligned, compact, rounded-md
   =================================================================== */
.thread-post-page .dify-chat__choice {
  appearance: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  box-sizing: border-box;
  margin-top: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: var(--line-height-base);
  text-align: left;
  color: var(--color-text-primary);
  background: var(--color-base-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: normal;
  word-break: break-word;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.thread-post-page .dify-chat__choice:hover:not(:disabled) {
  background: color-mix(in srgb, var(--color-main) 8%, var(--color-base-1));
  border-color: var(--color-main);
}

.thread-post-page .dify-chat__choice:focus-visible {
  outline: 2px solid var(--color-main);
  outline-offset: 2px;
}

/* 8+ buttons: inline chips that wrap */
.thread-post-page .dify-chat__bubble--many-choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.thread-post-page .dify-chat__bubble--many-choices > p,
.thread-post-page .dify-chat__bubble--many-choices > hr,
.thread-post-page .dify-chat__bubble--many-choices > table,
.thread-post-page .dify-chat__bubble--many-choices > div {
  width: 100%;
  flex-shrink: 0;
}

.thread-post-page .dify-chat__bubble--many-choices .dify-chat__choice {
  width: auto;
  display: inline-flex;
  margin-top: 0;
  padding: var(--space-2) var(--space-3);
  white-space: nowrap;
}

/* ===================================================================
   Input bar — sticky, gradient fade, white bar with shadow
   =================================================================== */
.thread-post-chat__input-wrap {
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: var(--space-4) 0;
  background: linear-gradient(to bottom, transparent, var(--color-base-2) 30%);
}

.thread-post-chat__input-wrap[hidden] {
  display: none;
}

.thread-post-chat__input-form {
  margin: 0;
}

.thread-post-chat__input-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-base-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
}

.thread-post-chat__textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--color-text-primary);
  background: transparent;
  padding: var(--space-2) 0;
  /* 初期表示は2行分。入力内容や改行に応じて JS の自動リサイズで広がる。 */
  min-height: calc(2 * 1.6em + 2 * var(--space-2));
  max-height: min(40vh, 12rem);
  overflow-y: hidden;
  box-sizing: border-box;
}

.thread-post-chat__textarea::placeholder {
  color: var(--color-text-muted);
}

/* スマホ表示時は初期3行の高さを確保 */
@media (max-width: 768px) {
  .thread-post-chat__textarea {
    min-height: calc(3 * 1.6em + 2 * var(--space-2));
  }
}

/* 入力エリア下の字数カウンター */
.thread-post-chat__counter {
  margin: var(--space-1) var(--space-2) 0;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.thread-post-chat__counter--over {
  color: var(--color-error);
  font-weight: 600;
}

.thread-post-chat__send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-full);
  background: var(--color-main);
  color: var(--color-base-1);
  cursor: pointer;
  transition: filter var(--transition-fast);
}

.thread-post-chat__send:hover:not(:disabled) {
  filter: brightness(1.08);
}

.thread-post-chat__send:focus-visible {
  outline: 2px solid var(--color-main);
  outline-offset: 2px;
}

.thread-post-chat__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===================================================================
   Submit wrap (Dify-generated confirmation area)
   =================================================================== */
.thread-post-page .dify-chat__submit-wrap {
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-base-2);
  text-align: center;
}

.thread-post-page .dify-chat__submit-desc {
  margin: 0 0 var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* ===================================================================
   Completion card
   =================================================================== */
.thread-post-complete {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-12) var(--space-6);
  text-align: center;
  background: var(--color-base-1);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-figma-card);
}

.thread-post-complete__icon {
  font-size: 3rem;
  line-height: 1;
}

.thread-post-complete__title {
  margin: 0;
  font-size: var(--font-size-2xl);
  font-weight: 900;
  color: var(--color-text-primary);
}

.thread-post-complete__body {
  margin: 0;
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  line-height: 1.7;
}

.thread-post-complete__cta {
  display: inline-flex;
}

/* 完了メッセージをチャットログ末尾に表示（アシスタント行の延長） */
.thread-post-page .thread-post-chat__msg--complete .dify-chat__bubble--thread-complete {
  max-width: 100%;
}

.thread-post-complete--in-chat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 0;
  text-align: left;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.thread-post-complete--in-chat .thread-post-complete__icon {
  font-size: 2rem;
  line-height: 1;
}

.thread-post-complete--in-chat .thread-post-complete__title {
  font-size: var(--font-size-xl);
  font-weight: 800;
}

.thread-post-complete--in-chat .thread-post-complete__body {
  margin: 0;
}

.thread-post-complete--in-chat .thread-post-complete__cta {
  margin-top: var(--space-2);
}

/* ===================================================================
   Typing indicator — "入力しています…" row (mock-chat-typing)
   =================================================================== */
.thread-post-chat__msg--typing {
  display: flex;
  gap: var(--space-3);
  max-width: 100%;
}

.thread-post-chat__typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-base-2);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  border-top-left-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.thread-post-chat__typing-text {
  font-weight: 600;
}

/* ===================================================================
   Typing dots — 検索ページと同じ「波打つ 3 点ドット」表現
   3 つの span を順番に上下にバウンドさせる。
   =================================================================== */
.thread-post-chat__typing-dots {
  display: inline-flex;
  align-items: flex-end;
  gap: 5px;
  height: 12px;
}

.thread-post-chat__typing-dots span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-main, #208747);
  opacity: 0.6;
  animation: thread-post-typing-wave 1.4s ease-in-out infinite;
}

.thread-post-chat__typing-dots span:nth-child(1) { animation-delay: 0s; }
.thread-post-chat__typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.thread-post-chat__typing-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes thread-post-typing-wave {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.55; }
  30%           { transform: translateY(-5px); opacity: 1;    }
}

/* ===================================================================
   Typewriter cursor — blinking pipe during char-by-char reveal
   =================================================================== */
@keyframes thread-post-cursor-blink {
  0%, 45% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.thread-post-chat__type-cursor {
  display: inline-block;
  width: 0.12em;
  min-width: 2px;
  height: 1.1em;
  margin-left: 1px;
  background-color: var(--color-main);
  vertical-align: -0.12em;
  animation: thread-post-cursor-blink 1s steps(1, end) infinite;
}

/* ===================================================================
   Reduced motion — disable all chat animations
   =================================================================== */
@media (prefers-reduced-motion: reduce) {
  .thread-post-chat__typing-dots span {
    animation: none;
    opacity: 0.85;
    transform: none;
  }

  .thread-post-chat__type-cursor {
    animation: none;
    opacity: 1;
  }
}

/* ===================================================================
   Responsive — small screens
   =================================================================== */
@media (max-width: 640px) {
  .thread-post-page .dify-chat__bubble {
    max-width: 92%;
    padding: var(--space-3) var(--space-4);
  }

  .thread-post-anon {
    padding: var(--space-3) var(--space-4);
  }

  .thread-post-anon__hint {
    padding-left: 0;
  }
}

/* ===================================================================
   体験談投稿 /threads/{id}/answer/（body.answer-post-page）
   =================================================================== */
body.answer-post-page .answer-post-page__bubble-lead {
  font-weight: 700;
}

body.answer-post-page .thread-post-chat__answer-register {
  margin-top: var(--space-4);
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
  width: 100%;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__actions .thread-post-complete__cta {
  margin-top: 0;
}

/* ===================================================================
   Completion card — thanks 動画 + X シェア CTA（Phase 4）
   - 動画は 1 回再生（loop なし）。reduced-motion 環境では JS 側で要素ごと除去
     するが、CSS でも保険として非表示にしておく。
   - 当ページでは button.css をロードしていないため、CTA は `.btn` に頼らず
     完了カード内で完結する独立スタイルを定義する。
   - 視覚的優先度: X でポストする（最も目立つ / 黒地白文字）>
     相談を見る（メインカラー塗り）> TOPに戻る（メインカラーのアウトライン）。
   =================================================================== */
body.answer-post-page .thread-post-complete--in-chat {
  gap: var(--space-4);
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__media {
  width: 100%;
  margin: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-base-2);
  line-height: 0;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__video {
  display: block;
  width: 100%;
  height: auto; /* 動画本来のアスペクト比を維持し上下クロップを起こさない */
  max-width: 100%;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__title {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: 800;
  line-height: 1.4;
  color: var(--color-text-primary);
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__body {
  margin: 0;
  color: var(--color-text-secondary);
  line-height: 1.7;
}

/* --- 共通 CTA ベース（.btn に依存しない） --------------------------- */
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin: 0;
  padding: 14px 24px;
  border-radius: var(--radius-full);
  border: 1.5px solid transparent;
  font-size: var(--font-size-base);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  box-sizing: border-box;
  cursor: pointer;
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast),
    opacity var(--transition-fast);
}

/* --- X 共有: 黒地・白文字・全幅。最も視覚優先度が高い ---------------- */
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__share {
  display: flex;
  width: 100%;
  margin-top: var(--space-1);
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__cta--x {
  flex: 1 1 auto;
  padding: 16px 24px;
  background-color: #0f1419;
  color: var(--color-text-inverse);
  border-color: #0f1419;
  font-size: var(--font-size-lg);
  box-shadow: 0 6px 18px rgba(15, 20, 25, 0.22);
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__cta--x:hover,
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__cta--x:focus-visible {
  background-color: #000;
  border-color: #000;
  color: var(--color-text-inverse);
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(15, 20, 25, 0.28);
  outline: none;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__cta-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: currentColor;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__cta-label {
  font-weight: 700;
}

/* --- 二次アクション行（相談を見る / TOPに戻る） -------------------- */
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-2);
  width: 100%;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__actions .thread-post-complete__cta {
  flex: 1 1 calc(50% - var(--space-3));
  min-width: 0;
}

/* 相談を見る: メインカラー塗りの強アクション */
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__cta--secondary {
  background-color: var(--color-main);
  color: var(--color-text-inverse);
  border-color: var(--color-main);
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__cta--secondary:hover,
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__cta--secondary:focus-visible {
  background-color: var(--color-accent-2, var(--color-main));
  border-color: var(--color-accent-2, var(--color-main));
  color: var(--color-text-inverse);
  opacity: 1;
  outline: none;
}

/* TOPに戻る: アウトラインのゴーストボタン */
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__cta--top {
  background-color: transparent;
  color: var(--color-main);
  border-color: var(--color-main);
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__cta--top:hover,
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__cta--top:focus-visible {
  background-color: color-mix(in srgb, var(--color-main) 10%, transparent);
  color: var(--color-main);
  opacity: 1;
  outline: none;
}

@media (max-width: 480px) {
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__actions {
    flex-direction: column;
  }
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__actions .thread-post-complete__cta {
    flex: 1 1 auto;
    width: 100%;
  }
}

/* ===================================================================
   体験談投稿完了 リッチヒーロー版
   - 動画の下に「YOUR STORY ヒーロー → 感謝メッセージ → 投稿プレビュー
     → X CTA → 既存ナビ」を縦に積む。
   - 全体は `.thread-post-complete--in-chat` のフレックス縦並びを継承。
   - 既存 .thread-post-complete__cta--x / --secondary / --top はそのまま使う。
   =================================================================== */

/* --- セクション 1: HERO（YOUR STORY + conflict_title 引用） --------- */
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero {
  position: relative;
  width: 100%;
  margin: 0;
  padding: 48px 32px 40px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--cat-kachi-bg) 0%, #FFF3F9 65%, var(--color-base-1) 100%);
  text-align: center;
  overflow: hidden;
  box-sizing: border-box;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero-eyebrow {
  margin: 0 0 28px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: var(--cat-kachi-text, #b21b68);
  text-transform: uppercase;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero-quote {
  position: relative;
  margin: 0 auto;
  max-width: 22em;
  padding: 0;
  font-family: 'Noto Serif JP', 'Hiragino Mincho ProN', 'YuMincho', 'Yu Mincho', serif;
  font-size: clamp(22px, 4.4vw, 30px);
  font-weight: 700;
  line-height: 1.55;
  color: var(--color-text-primary);
  letter-spacing: 0.02em;
  z-index: 1;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero-deco {
  position: absolute;
  width: 40px;
  height: auto;
  color: #f4a8c8;
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero-deco svg {
  display: block;
  width: 100%;
  height: auto;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero-deco--lt {
  top: 36px;
  left: 18%;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero-deco--rb {
  right: 18%;
  bottom: 90px;
  transform: rotate(180deg);
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero-caption {
  margin: 28px 0 0;
  font-size: 13px;
  color: var(--color-text-secondary);
  letter-spacing: 0.04em;
}

/* --- セクション 2: 感謝メッセージ ---------------------------------- */
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__thanks {
  width: 100%;
  margin: 0;
  padding: 32px 8px 8px;
  text-align: center;
  box-sizing: border-box;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__thanks-title {
  margin: 0 0 12px;
  font-size: clamp(20px, 3.6vw, 26px);
  font-weight: 900;
  line-height: 1.4;
  color: var(--color-text-primary);
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__thanks-lead {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text-secondary);
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__thanks-hl {
  margin: 22px 0 0;
  font-size: clamp(16px, 2.8vw, 18px);
  font-weight: 700;
  line-height: 1.5;
  color: var(--color-text-primary);
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__thanks-sub {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.85;
  color: var(--color-text-muted);
}

/* --- セクション 3: 投稿プレビュー（X モック） ---------------------- */
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__preview {
  position: relative;
  width: 100%;
  max-width: 540px;
  margin: 16px auto 0;
  padding: 22px 18px 16px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-base-1);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  box-sizing: border-box;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__preview-badge {
  position: absolute;
  top: -10px;
  left: 16px;
  display: inline-block;
  padding: 2px 10px;
  background: var(--color-base-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__tweet {
  display: block;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__tweet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__tweet-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  background: var(--color-border-light);
  color: var(--color-text-secondary);
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__tweet-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__tweet-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-primary);
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__tweet-handle {
  font-size: 12px;
  color: var(--color-text-muted);
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__tweet-body {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text-primary);
  word-break: break-word;
  overflow-wrap: anywhere;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__tweet-card {
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: #fafafa;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__tweet-card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--color-text-primary);
  word-break: break-word;
  overflow-wrap: anywhere;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__tweet-card-domain {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--color-text-muted);
  word-break: break-all;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__tweet-card-source {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

/* --- セクション 4: X CTA フットノート --------------------------- */
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__share {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__cta-foot {
  margin: 0;
  font-size: 12px;
  text-align: center;
  color: var(--color-text-muted);
  line-height: 1.6;
}

/* --- レスポンシブ（small） --------------------------------------- */
@media (max-width: 480px) {
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero {
    padding: 36px 18px 32px;
  }
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero-deco {
    width: 28px;
  }
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero-deco--lt {
    top: 28px;
    left: 10%;
  }
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero-deco--rb {
    right: 10%;
    bottom: 72px;
  }
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__thanks {
    padding: 24px 4px 4px;
  }
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__preview {
    margin: 12px auto 0;
    padding: 20px 14px 14px;
  }
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__tweet-body {
    font-size: 13px;
  }
}

/* --- 入場アニメーション（任意・小さく） --------------------------- */
@keyframes thread-post-complete-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero,
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__thanks,
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__preview,
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__share,
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__actions {
  animation: thread-post-complete-fade-up 420ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero    { animation-delay: 60ms; }
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__thanks  { animation-delay: 160ms; }
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__preview { animation-delay: 240ms; }
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__share   { animation-delay: 320ms; }
body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__actions { animation-delay: 380ms; }

@media (prefers-reduced-motion: reduce) {
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__media {
    display: none;
  }
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__cta {
    transition: none;
  }
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__hero,
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__thanks,
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__preview,
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__share,
  body.answer-post-page .thread-post-complete--in-chat .thread-post-complete__actions {
    animation: none;
  }
}

/* ===================================================================
   相談スレ投稿完了カード（/post/thread）
   - 「登録しています…」のお知らせ + thanks2.mp4 + TOPに戻る CTA。
   - 当ページも button.css をロードしていないので CTA は独立スタイル。
   =================================================================== */
body.thread-post-page .thread-post-complete--in-chat {
  gap: var(--space-4);
}

body.thread-post-page .thread-post-complete--in-chat .thread-post-complete__icon {
  font-size: 2.5rem;
  line-height: 1;
}

body.thread-post-page .thread-post-complete--in-chat .thread-post-complete__title {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: 800;
  line-height: 1.4;
  color: var(--color-text-primary);
}

body.thread-post-page .thread-post-complete--in-chat .thread-post-complete__media {
  width: 100%;
  margin: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-base-2);
  line-height: 0;
}

body.thread-post-page .thread-post-complete--in-chat .thread-post-complete__video {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

body.thread-post-page .thread-post-complete--in-chat .thread-post-complete__body {
  margin: 0;
  color: var(--color-text-secondary);
  line-height: 1.8;
}

body.thread-post-page .thread-post-complete--in-chat .thread-post-complete__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-2);
  width: 100%;
}

/* --- CTA: .btn 非依存の独立スタイル -------------------------------- */
body.thread-post-page .thread-post-complete--in-chat .thread-post-complete__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin: 0;
  padding: 14px 28px;
  border-radius: var(--radius-full);
  border: 1.5px solid transparent;
  font-size: var(--font-size-base);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  box-sizing: border-box;
  cursor: pointer;
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast),
    opacity var(--transition-fast);
}

/* TOPに戻る: メインカラー塗りの強アクション */
body.thread-post-page .thread-post-complete--in-chat .thread-post-complete__cta--top {
  background-color: var(--color-main);
  color: var(--color-text-inverse);
  border-color: var(--color-main);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--color-main) 28%, transparent);
}

body.thread-post-page .thread-post-complete--in-chat .thread-post-complete__cta--top:hover,
body.thread-post-page .thread-post-complete--in-chat .thread-post-complete__cta--top:focus-visible {
  background-color: var(--color-accent-2, var(--color-main));
  border-color: var(--color-accent-2, var(--color-main));
  color: var(--color-text-inverse);
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--color-main) 32%, transparent);
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  body.thread-post-page .thread-post-complete--in-chat .thread-post-complete__media {
    display: none;
  }
  body.thread-post-page .thread-post-complete--in-chat .thread-post-complete__cta {
    transition: none;
  }
}

/* ===================================================================
   体験談投稿ページ 初回バブル内 3 ステップ構成図プレビュー
   - 初回 AI バブル内に「① 葛藤 → ② 転機 → ③ 変化」の構成を視覚化。
   - タイプライターで AI バブルの「ぜひ、〜お聞かせください。」直後に挿入され、
     CSS アニメ（合計 ~3.2s）→ 1s 余白 → 「①【葛藤】…」のタイプ再開。
   - チャットバブル内に「平置き」する想定で、白カード装飾は付けない。
   - `.thread-post-page .dify-chat__bubble p { margin: 0 0 var(--space-3); }`
     を上書きするため、内部 <p> の margin 系は同じ親（.dify-chat__bubble）配下に
     スコープして specificity を確保。
   =================================================================== */
.litstories-steps {
  --accent: #14B8A6;
  --border: var(--color-border);
  --text-main: #1F2937;
  --text-sub: #4B5563;
  --text-muted: var(--color-text-secondary);

  width: 100%;
  max-width: 100%;
  margin: var(--space-3) 0 var(--space-3);
  font-family: inherit;
}

.thread-post-page .dify-chat__bubble .litstories-steps p {
  margin: 0;
}

.litstories-steps__header {
  text-align: center;
  margin-bottom: 28px;
}

.thread-post-page .dify-chat__bubble .litstories-steps__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 6px;
}

.thread-post-page .dify-chat__bubble .litstories-steps__subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.litstories-steps__row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.litstories-steps__card {
  flex: 1 1 0;
  max-width: 260px;
  background: var(--color-base-1);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 24px 16px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-sizing: border-box;
}

.litstories-steps__icon {
  width: 56px;
  height: 56px;
  margin-bottom: 14px;
}

.litstories-steps__title-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
}

.litstories-steps__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--color-text-inverse);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.litstories-steps__label {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.thread-post-page .dify-chat__bubble .litstories-steps__desc {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.6;
  margin: 0;
}

.litstories-steps__arrow {
  flex: 0 0 auto;
  width: 40px;
  height: 24px;
  color: var(--accent);
}

.litstories-steps__arrow svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ====== アニメーション ====== */
/* `--paused` 状態では animation-play-state を paused にして、
   タイプライター演出が完了するまで再生開始を遅らせる。
   完了時に JS が `litstories-steps--paused` クラスを外す。 */
.litstories-steps .anim {
  opacity: 0;
  animation: ls-fadeIn 0.5s ease-out forwards;
}
.litstories-steps .anim--header-1 { animation-delay: 0s; }
.litstories-steps .anim--header-2 { animation-delay: 0.25s; }
.litstories-steps .anim--card-1   { animation-delay: 0.6s; }
.litstories-steps .anim--arrow-1  { animation-delay: 1.15s; }
.litstories-steps .anim--card-2   { animation-delay: 1.65s; }
.litstories-steps .anim--arrow-2  { animation-delay: 2.2s; }
.litstories-steps .anim--card-3   { animation-delay: 2.7s; }

.litstories-steps .arrow-line {
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: ls-drawLine 0.4s ease-out forwards;
}
.litstories-steps .anim--arrow-1 .arrow-line { animation-delay: 1.15s; }
.litstories-steps .anim--arrow-2 .arrow-line { animation-delay: 2.2s; }

.litstories-steps .arrow-head {
  opacity: 0;
  animation: ls-fadeIn 0.2s ease-out forwards;
}
.litstories-steps .anim--arrow-1 .arrow-head { animation-delay: 1.45s; }
.litstories-steps .anim--arrow-2 .arrow-head { animation-delay: 2.5s; }

.litstories-steps--paused .anim,
.litstories-steps--paused .arrow-line,
.litstories-steps--paused .arrow-head {
  animation-play-state: paused;
}

@keyframes ls-fadeIn { to { opacity: 1; } }
@keyframes ls-drawLine { to { stroke-dashoffset: 0; } }

/* ====== スマホ: 縦配置 ====== */
@media (max-width: 720px) {
  .litstories-steps__row {
    flex-direction: column;
    gap: 8px;
  }
  .litstories-steps__card {
    max-width: 320px;
    width: 100%;
  }
  .litstories-steps__arrow {
    width: 24px;
    height: 32px;
  }
  .litstories-steps__arrow svg {
    transform: rotate(90deg);
  }
}

/* ====== アクセシビリティ: アニメ無効化対応 ====== */
@media (prefers-reduced-motion: reduce) {
  .litstories-steps .anim,
  .litstories-steps .arrow-line,
  .litstories-steps .arrow-head {
    animation: none !important;
    opacity: 1 !important;
    stroke-dashoffset: 0 !important;
  }
}

/* ===================================================================
   相談投稿 確認フォーム（Difyリライト後の最終確認画面）
   - body / title / 質問チェック を編集して /threads/create に投げる
   - 表示制御は JS の hidden 属性で行う（[hidden] は CSS でも保険として隠す）
   =================================================================== */
.thread-post-confirm[hidden] {
  display: none;
}

.thread-post-confirm,
.answer-post-confirm {
  background: var(--color-base-2);
  padding: var(--space-8) var(--space-4) var(--space-12);
}

.thread-post-confirm__inner,
.answer-post-confirm__inner {
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
  background: var(--color-base-1);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-figma-card);
  padding: var(--space-8);
  box-sizing: border-box;
}

@media (max-width: 640px) {
  .thread-post-confirm,
  .answer-post-confirm {
    padding: var(--space-6) var(--space-3) var(--space-12);
  }
  .thread-post-confirm__inner,
  .answer-post-confirm__inner {
    padding: var(--space-6) var(--space-4);
  }
}

/* --- ヘッダー --- */
.thread-post-confirm__header,
.answer-post-confirm__header {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  text-align: center;
}

.thread-post-confirm__eyebrow,
.answer-post-confirm__eyebrow {
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--color-main);
  text-transform: uppercase;
}

.thread-post-confirm__title-heading {
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-2xl);
  font-weight: 900;
  line-height: 1.4;
  color: var(--color-text-primary);
}

.thread-post-confirm__lead,
.answer-post-confirm__lead {
  margin: 0;
  font-size: var(--font-size-sm);
  line-height: 1.7;
  color: var(--color-text-secondary);
}

.answer-post-confirm__thread-ref {
  margin: var(--space-3) 0 0;
  font-size: var(--font-size-sm);
  line-height: 1.7;
  color: var(--color-text-secondary);
}

.answer-post-confirm__thread-link {
  color: var(--color-main);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.answer-post-confirm__thread-link:hover,
.answer-post-confirm__thread-link:focus-visible {
  color: var(--color-accent-2, var(--color-main));
  outline: none;
}

/* --- フォーム --- */
.thread-post-confirm__form,
.answer-post-confirm__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  margin: 0;
}

.thread-post-confirm__field,
.answer-post-confirm__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.thread-post-confirm__label,
.answer-post-confirm__label {
  display: block;
  margin: 0;
  font-size: var(--font-size-sm);
  font-weight: 700;
  line-height: 1.6;
  color: var(--color-text-primary);
}

/* 体験談確認フォームのラベルは入力欄を目立たせるため控えめなグレーにする */
.answer-post-confirm__label {
  color: var(--color-text-secondary);
  opacity: 0.6;
}

.thread-post-confirm__label--sub {
  margin-top: var(--space-3);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
}

.thread-post-confirm__label-row,
.answer-post-confirm__label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.thread-post-confirm__counter,
.answer-post-confirm__counter {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* --- 件名入力 --- */
.thread-post-confirm__title,
.answer-post-confirm__title {
  display: block;
  width: 100%;
  box-sizing: border-box;
  /* JSの高さ計算が走る前でも1行分は確実に表示されるよう保険。
     line-height(1.5em) + padding上下(var(--space-3)*2) + border上下(2px) */
  min-height: calc(1.5em + var(--space-3) * 2 + 2px);
  padding: var(--space-3) var(--space-4);
  font-family: inherit;
  font-size: var(--font-size-base);
  font-weight: 700;
  line-height: 1.5;
  color: var(--color-text-primary);
  background: var(--color-base-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  /* textarea 化したことで折り返し可能。手動リサイズハンドルは隠し、JSで行数に合わせて高さ可変。 */
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.thread-post-confirm__title:focus,
.thread-post-confirm__body:focus,
.thread-post-confirm__custom-q:focus,
.answer-post-confirm__title:focus,
.answer-post-confirm__body:focus {
  outline: none;
  border-color: var(--color-main);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-main) 20%, transparent);
}

/* --- 本文 textarea --- */
.thread-post-confirm__body,
.answer-post-confirm__body {
  width: 100%;
  box-sizing: border-box;
  min-height: 200px;
  padding: var(--space-4);
  font-family: inherit;
  font-size: var(--font-size-base);
  line-height: 1.8;
  color: var(--color-text-primary);
  background: var(--color-base-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  resize: vertical;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

/* --- 相談者へのメッセージ欄（目立たせる淡いピンク背景） --- */
.answer-post-confirm__body--message {
  background: var(--color-message-box-bg);
}

/* --- 質問チェックボックス --- */
.thread-post-confirm__choices {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.thread-post-confirm__choice {
  margin: 0;
}

.thread-post-confirm__choice-label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-base-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.thread-post-confirm__choice-label:hover {
  background: color-mix(in srgb, var(--color-main) 6%, var(--color-base-1));
  border-color: var(--color-main);
}

.thread-post-confirm__choice-input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--color-main);
  cursor: pointer;
}

.thread-post-confirm__choice-input:focus-visible {
  outline: 2px solid var(--color-main);
  outline-offset: 2px;
}

.thread-post-confirm__choice-text {
  flex: 1;
  font-size: var(--font-size-sm);
  line-height: 1.6;
  color: var(--color-text-primary);
  word-break: break-word;
}

.thread-post-confirm__choice-label:has(.thread-post-confirm__choice-input:checked) {
  background: color-mix(in srgb, var(--color-main) 8%, var(--color-base-1));
  border-color: var(--color-main);
}

/* --- 自由記入欄 --- */
.thread-post-confirm__custom-q {
  width: 100%;
  box-sizing: border-box;
  padding: var(--space-3) var(--space-4);
  font-family: inherit;
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text-primary);
  background: var(--color-base-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.thread-post-confirm__note,
.answer-post-confirm__note {
  margin: 0;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-align: right;
}

/* --- インラインエラー（バリデーション失敗時） --- */
.thread-post-confirm__error[hidden],
.answer-post-confirm__error[hidden] {
  display: none;
}

.thread-post-confirm__error,
.answer-post-confirm__error {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  background: color-mix(in srgb, var(--color-error) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-error) 40%, transparent);
  border-radius: var(--radius-md);
  color: var(--color-error);
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1.5;
}

/* --- 登録完了（フォーム内・ボタンの位置に挿入） --- */
.thread-post-confirm__actions[hidden],
.thread-post-confirm__foot[hidden],
.answer-post-confirm__actions[hidden],
.answer-post-confirm__foot[hidden] {
  display: none;
}

.thread-post-confirm__complete,
.answer-post-confirm__complete {
  margin-top: var(--space-2);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border-light);
}

.thread-post-complete--in-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: 0;
  text-align: center;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.thread-post-complete--in-form .thread-post-complete__icon {
  font-size: 2.5rem;
  line-height: 1;
}

.thread-post-complete--in-form .thread-post-complete__title {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--color-text-primary);
}

.thread-post-complete--in-form .thread-post-complete__body {
  margin: 0;
  color: var(--color-text-secondary);
  line-height: 1.8;
}

.thread-post-complete--in-form .thread-post-complete__media {
  width: 100%;
  max-width: 360px;
  margin: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-base-2);
  line-height: 0;
}

.thread-post-complete--in-form .thread-post-complete__video {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.thread-post-complete--in-form .thread-post-complete__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
  width: 100%;
}

.thread-post-complete--in-form .thread-post-complete__cta--secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 14px 28px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-main);
  background-color: var(--color-base-1);
  color: var(--color-main);
  font-size: var(--font-size-base);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast);
}

.thread-post-complete--in-form .thread-post-complete__cta--secondary:hover,
.thread-post-complete--in-form .thread-post-complete__cta--secondary:focus-visible {
  background-color: color-mix(in srgb, var(--color-main) 10%, var(--color-base-1));
  outline: none;
}

.thread-post-complete--in-form .thread-post-complete__cta--top {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 14px 28px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-main);
  background-color: var(--color-main);
  color: var(--color-text-inverse);
  font-size: var(--font-size-base);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--color-main) 28%, transparent);
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast);
}

.thread-post-complete--in-form .thread-post-complete__cta--top:hover,
.thread-post-complete--in-form .thread-post-complete__cta--top:focus-visible {
  background-color: var(--color-accent-2, var(--color-main));
  border-color: var(--color-accent-2, var(--color-main));
  transform: translateY(-1px);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--color-main) 32%, transparent);
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  .thread-post-complete--in-form .thread-post-complete__media {
    display: none;
  }
}

/* 登録完了後は入力欄を読み取り専用表示にする */
.thread-post-confirm__title[readonly],
.thread-post-confirm__body[readonly],
.thread-post-confirm__custom-q[readonly],
.answer-post-confirm__title[readonly],
.answer-post-confirm__body[readonly] {
  background: var(--color-base-2);
  color: var(--color-text-secondary);
  cursor: default;
}

.thread-post-confirm__choice-input:disabled + .thread-post-confirm__choice-text,
.thread-post-confirm__choice-input:disabled ~ .thread-post-confirm__choice-text {
  color: var(--color-text-secondary);
}

/* --- アクション/送信ボタン --- */
.thread-post-confirm__actions,
.answer-post-confirm__actions {
  display: flex;
  justify-content: center;
  margin-top: var(--space-4);
}

.thread-post-confirm__submit,
.answer-post-confirm__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-width: 280px;
  padding: 16px 32px;
  font-family: inherit;
  font-size: var(--font-size-lg);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-base-1);
  background: var(--color-main);
  border: 1.5px solid var(--color-main);
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--color-main) 28%, transparent);
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast),
    opacity var(--transition-fast);
}

.thread-post-confirm__submit:hover:not(:disabled),
.thread-post-confirm__submit:focus-visible,
.answer-post-confirm__submit:hover:not(:disabled),
.answer-post-confirm__submit:focus-visible {
  background: var(--color-accent-2, var(--color-main));
  border-color: var(--color-accent-2, var(--color-main));
  transform: translateY(-1px);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--color-main) 32%, transparent);
  outline: none;
}

.thread-post-confirm__submit:disabled,
.answer-post-confirm__submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.thread-post-confirm__submit-icon,
.answer-post-confirm__submit-icon {
  font-size: 1.1em;
  font-weight: 700;
}

.thread-post-confirm__foot,
.answer-post-confirm__foot {
  margin: 0;
  text-align: center;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  line-height: 1.7;
}

@media (max-width: 480px) {
  .thread-post-confirm__submit,
  .answer-post-confirm__submit {
    min-width: 0;
    width: 100%;
  }
}

/* ============================================================================
   answer-post-confirm 固有: イントロのリンク・案内リスト と スレ プレビュー モーダル
   ============================================================================ */

.answer-post-chat__thread-link {
  color: var(--color-main);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.answer-post-chat__thread-link:hover,
.answer-post-chat__thread-link:focus-visible {
  color: var(--color-accent-2, var(--color-main));
  outline: none;
}

/* --- スレ プレビュー モーダル --- */
.thread-preview-modal {
  border: none;
  padding: 0;
  background: transparent;
  width: min(720px, calc(100vw - var(--space-6)));
  max-height: calc(100vh - var(--space-12));
  border-radius: var(--radius-xl);
  color: var(--color-text-primary);
  /* ブラウザによっては <dialog> の margin が 0 になり左寄せになるため auto で中央揃えを保証 */
  margin: auto;
}

.thread-preview-modal::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

.thread-preview-modal[open] {
  display: block;
}

.thread-preview-modal__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--color-base-1);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-figma-card);
  max-height: calc(100vh - var(--space-12));
  overflow: hidden;
}

.thread-preview-modal__close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 36px;
  height: 36px;
  border: none;
  background: var(--color-base-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.thread-preview-modal__close:hover,
.thread-preview-modal__close:focus-visible {
  background: var(--color-border-light);
  color: var(--color-text-primary);
  outline: none;
}

.thread-preview-modal__header {
  padding: var(--space-6) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
}

.thread-preview-modal__eyebrow {
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.thread-preview-modal__title {
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-xl);
  font-weight: 800;
  line-height: 1.4;
  color: var(--color-text-primary);
}

.thread-preview-modal__author {
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.thread-preview-modal__body {
  padding: var(--space-5) var(--space-6);
  overflow-y: auto;
  flex: 1 1 auto;
}

.thread-preview-modal__h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text-primary);
}

.thread-preview-modal__h3:not(:first-child) {
  margin-top: var(--space-5);
}

.thread-preview-modal__prose {
  margin: 0;
  line-height: 1.8;
  color: var(--color-text-primary);
}

.thread-preview-modal__prose p {
  margin: 0 0 var(--space-3);
}

.thread-preview-modal__questions {
  margin: 0;
  padding-inline-start: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  color: var(--color-text-primary);
  line-height: 1.7;
}

.thread-preview-modal__questions > li {
  list-style: disc;
}

.thread-preview-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border-light);
  background: var(--color-base-2);
}

.thread-preview-modal__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-main);
  background: var(--color-main);
  color: var(--color-base-1);
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.thread-preview-modal__cta:hover,
.thread-preview-modal__cta:focus-visible {
  background: var(--color-accent-2, var(--color-main));
  border-color: var(--color-accent-2, var(--color-main));
  outline: none;
}

.thread-preview-modal__close-btn {
  border: 1px solid var(--color-border);
  background: var(--color-base-1);
  color: var(--color-text-primary);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.thread-preview-modal__close-btn:hover,
.thread-preview-modal__close-btn:focus-visible {
  background: var(--color-base-2);
  outline: none;
}

@media (max-width: 480px) {
  .thread-preview-modal {
    width: calc(100vw - var(--space-4));
  }
  .thread-preview-modal__header,
  .thread-preview-modal__body {
    padding-inline: var(--space-4);
  }
  .thread-preview-modal__footer {
    padding-inline: var(--space-4);
    flex-wrap: wrap;
  }
}
