* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: #f5f5f7;
  display: flex;
  justify-content: center;
  /* 横方向だけ中央寄せ */
  align-items: stretch;
  /* 縦は画面いっぱいに伸ばす */
}


.app {
  width: 100%;
  max-width: 520px;
  background: #ffffff;
  border-radius: 0px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;  /* 上〜下に並べる */
  overflow: hidden;
  flex: 1;                 /* 画面の高さまで伸ばす */
}


/* ヘッダー */
.header {
  padding: 10px 14px;
  border-bottom: 1px solid #eee;
  background: #111827;
  color: #f9fafb;
}

.header-title {
  font-size: 16px;
  font-weight: 600;
}

.header-sub {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
}

/* 銘柄検索 */
.stock-search {
  padding: 8px 10px 6px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

#stockSearch {
  width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  font-size: 12px;
  outline: none;
}

#stockSearch:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

/* 銘柄リスト */
.stock-list {
  display: flex;
  gap: 6px;
  padding: 4px 10px 8px;
  overflow-x: auto;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.stock-item {
  flex-shrink: 0;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  font-size: 11px;
  cursor: pointer;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 90px;
}

.stock-item-code {
  font-weight: 600;
  font-size: 11px;
  color: #111827;
}

.stock-item-name {
  font-size: 10px;
  color: #6b7280;
}

.stock-item.active {
  border-color: #2563eb;
  background: #eff6ff;
}

/* ステータスバー */
.status {
  display: none;
}

/* メッセージ一覧 */
.messages {
  flex: 1;                  /* ここが“伸びる真ん中ゾーン” */
  padding: 12px 12px 4px;
  overflow-y: auto;         /* ここだけ縦スクロール */
  background: #f9fafb;
}

.message {
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  font-size: 13px;
}

.message-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 11px;
  color: #6b7280;
}

.nickname {
  font-weight: 600;
}

.time {
  font-size: 10px;
}

.message-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #111827;
}

/* メッセージフッター（返信・通報ボタン） */
.message-footer {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
  font-size: 10px;
  color: #9ca3af;
  gap: 8px;
  align-items: center;
}

.report-btn {
  border: none;
  background: none;
  padding: 0;
  font-size: 10px;
  cursor: pointer;
}

.report-btn:disabled {
  opacity: 0.5;
  cursor: default;
  text-decoration: none;
}

/* 入力欄 */
.input-area {
  border-top: 1px solid #e5e7eb;
  padding: 8px;
  background: #ffffff;
  display: flex;
  gap: 6px;
  flex-shrink: 0;           /* ←これを追加！ 下に固定される */
}

#messageInput {
  flex: 1;
  resize: none;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}

#messageInput:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

#sendBtn {
  border: none;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #2563eb;
  color: white;
  white-space: nowrap;
}

#sendBtn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* 市場タブ */
.market-tabs {
  display: flex;
  gap: 6px;
  padding: 4px 10px 6px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  overflow-x: auto;
}

.market-tab {
  flex-shrink: 0;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #ffffff;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  color: #374151;
}

.market-tab.active {
  border-color: #2563eb;
  background: #2563eb;
  color: #ffffff;
}

/* 人気銘柄ランキング */
.popular-container {
  padding: 6px 10px 4px;
  border-bottom: 1px solid #e5e7eb;
  background: #ffffff;
}

.popular-title {
  font-size: 11px;
  color: #4b5563;
  margin-bottom: 4px;
}

.popular-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.popular-item {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.popular-rank {
  font-weight: 600;
  color: #2563eb;
}

.popular-code {
  font-weight: 600;
}

.popular-count {
  font-size: 10px;
  color: #6b7280;
}

/* 利用規約モーダル */
.tos-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.tos-dialog {
  width: calc(100% - 32px);
  max-width: 520px;
  max-height: 80vh;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tos-title {
  font-size: 16px;
  font-weight: 600;
  padding: 12px 16px;
  margin: 0;
  background: #111827;
  color: #f9fafb;
}

.tos-body {
  padding: 10px 16px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.6;
  color: #111827;
}

.tos-body h2 {
  font-size: 13px;
  margin: 10px 0 4px;
}

.tos-body ul {
  padding-left: 16px;
  margin: 0 0 6px;
}

.tos-body li {
  margin-bottom: 2px;
}

.tos-buttons {
  padding: 10px 12px 12px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #f9fafb;
}

.tos-accept,
.tos-decline {
  font-size: 12px;
  border-radius: 999px;
  padding: 6px 12px;
  border: 1px solid transparent;
  cursor: pointer;
}

.tos-accept {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.tos-decline {
  background: #ffffff;
  color: #4b5563;
  border-color: #d1d5db;
}

/* スレッド（返信）バー */
.reply-btn {
  border: none;
  background: none;
  padding: 0;
  font-size: 10px;
  cursor: pointer;
}

.reply-btn:disabled {
  opacity: 0.5;
  cursor: default;
  text-decoration: none;
}

.thread-btn {
  border: none;
  background: none;
  padding: 0;
  font-size: 10px;
  cursor: pointer;
}

/* もしフォーカス時の青い枠も消したかったらオプションで */
.thread-btn:focus {
  outline: none;
}

/* スレッドバー全体 */
.thread-bar {
  display: flex;
  /* デフォルトは表示しておいて、hidden クラスで消す */
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  font-size: 11px;
}

/* 非表示用クラス（最初はこれが付いている状態） */
.thread-bar--hidden {
  display: none;
}

/* 「メインに戻る」ボタン */
.thread-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
  margin-right: 8px;
}

.thread-back-btn::before {
  content: "←";
  font-size: 11px;
  margin-right: 4px;
}

.thread-back-btn:hover {
  background: #e5e7eb;
}

/* 親コメントの表示 */
.thread-parent {
  flex: 1;
  min-width: 0;
}

.thread-parent-label {
  font-size: 10px;
  color: #6b7280;
  margin-bottom: 2px;
}

.thread-parent-text {
  font-size: 12px;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  font-size: 11px;
}

/* 最初は非表示にしておく */
.reply-preview--hidden {
  display: none;
}

.reply-preview-label {
  font-weight: 500;
  color: #6b7280;
}

.reply-preview-text {
  flex: 1;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-cancel-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: #9ca3af;
  padding: 0 2px;
}

.reply-cancel-btn:hover {
  color: #4b5563;
}

/* メッセージ内の引用表示 */
.reply-quote {
  font-size: 11px;
  color: #6b7280;
  padding: 3px 6px;
  margin-bottom: 3px;
  border-left: 2px solid #d1d5db;
  background: #f9fafb;
  border-radius: 4px;
}

.message-body {
  display: flex;
  flex-direction: column;
}

/* 利用規約オーバーレイ */
#tosOverlay {
  /* もともとのレイアウト用のスタイル（position, backgroundなど）はそのまま */
  display: none;
  /* デフォルト非表示 */
}

#tosOverlay.is-open {
  display: flex;
  /* 表示するときだけ flex に */
}

/* ついでに空メッセージ用クラス（これはもうOK） */
.stock-empty-message {
  font-size: 11px;
  color: #9ca3af;
}