:root {
  --bg-color: #f7f7f7;
  --card-bg: #ffffff;
  --text-color: #222222;
  --primary-color: #c4c9d0;
  --author-color: #117743;
  --border-color: #d1d5db;
  --line-color: #e5e7eb;
  --sub-text-color: #6b7280;
  --link-color: #4b5563;
  --gap: 12px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar, body::-webkit-scrollbar {
  display: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.5;
}

.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: 800px;
  margin: 0 auto;
  background-color: var(--bg-color);
  overflow: hidden;
}

.bbs-header {
  padding: var(--gap);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.bbs-header-title {
  font-size: 1rem;
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bbs-header-title a {
  color: var(--text-color);
  text-decoration: none;
  display: flex;
  align-items: center;
}

.bbs-logo-img {
  max-height: 44px;
  width: auto;
  display: block;
}

.thread-select-link {
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--sub-text-color);
  font-weight: normal;
  background: transparent;
  padding: 0;
}
.thread-select-link:hover {
  color: var(--text-color);
}

.next-thread-bar {
  margin-top: 6px;
  padding: 8px 12px;
  border-radius: 6px;
  display: none;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}

.next-thread-bar.found {
  background: rgba(196, 201, 208, 0.2);
  border: 1px solid #c4c9d0;
}

.next-thread-bar.not-found {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid #dc2626;
  color: #dc2626;
}

.next-thread-btn {
  background: var(--primary-color);
  color: #ffffff;
  border: none;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  text-decoration: none;
  font-size: 0.85rem;
}

.next-thread-reload {
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
}

.bbs-status {
  font-size: 0.75rem;
  color: var(--sub-text-color);
}

.bbs-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--gap);
  min-height: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background-color: var(--card-bg);
}

.bbs-content.select-mode {
  background-color: var(--bg-color);
}

.bbs-content::-webkit-scrollbar {
  display: none;
}

.bbs-thread {
  background: transparent;
  border: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bbs-post {
  padding: 8px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line-color);
  font-size: 0.9rem;
  border-radius: 6px;
}

.bbs-post:last-child {
  border-bottom: none;
}

/* 古いレス（一律で文字色を薄くする） */
.bbs-post.old-post,
.bbs-post.old-post .bbs-post__name,
.bbs-post.old-post .bbs-post__mail,
.bbs-post.old-post .bbs-post__body,
.bbs-post.old-post .bbs-post__body a,
.bbs-post.old-post .bbs-post__anchor {
  color: #9ca3af !important;
}

.bbs-post__meta {
  font-size: 0.85rem;
  margin-bottom: 2px;
  position: relative;
  font-weight: normal;
}

.bbs-post__name {
  color: #888;
  cursor: pointer;
  text-decoration: none;
  font-weight: bold;
}

/* 自分の投稿の名前・本文を太字にする */
.bbs-post.my-post .bbs-post__name,
.bbs-post.my-post .bbs-post__body {
  font-weight: bold;
}

.bbs-post__name:hover {
  color: #5E5E5E;
}

.bbs-post__mail {
  color: var(--sub-text-color);
  margin-left: 4px;
  font-weight: normal;
}

.bbs-post__body {
  padding-left: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.5;
  font-weight: normal;
}

.bbs-post__body a,
.bbs-post__anchor {
  color: var(--link-color) !important;
  cursor: pointer;
}
.bbs-post__body a:hover,
.bbs-post__anchor:hover {
  color: var(--text-color) !important;
}

.popup-box {
  position: absolute;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-size: 0.85rem;
  z-index: 1000;
  max-width: 320px;
  display: none;
}

.name-menu-popup {
  position: absolute;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: none;
  z-index: 1001;
  font-size: 0.85rem;
  overflow: hidden;
}

.name-menu-item {
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.name-menu-item:hover {
  background: var(--bg-color);
}

.img-thumb {
  max-height: 80px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 4px;
  display: block;
}

.image-modal {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  display: none;
}

.image-modal img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 4px;
}

.error-container {
  padding: 16px;
  text-align: center;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.error-title {
  font-weight: bold;
  color: var(--text-color);
  margin-bottom: 12px;
}

.candidate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.candidate-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-color);
  font-size: 0.9rem;
  font-weight: bold;
}

.candidate-item:hover {
  border-color: var(--primary-color);
}

.bbs-footer {
  padding: var(--gap);
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 10;
}

.bbs-form__grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bbs-form__row-top {
  display: flex;
  gap: 6px;
  align-items: center;
}

.bbs-form__input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  background-color: var(--card-bg);
  color: var(--text-color);
}

.bbs-form__clear {
  width: 70px;
  height: 40px;
  background: var(--bg-color);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bbs-form__clear:hover {
  background: var(--border-color);
}

.bbs-form__textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  background-color: var(--card-bg);
  color: var(--text-color);
  resize: none;
  height: 50px;
}

.bbs-form__submit {
  width: 100%;
  height: 40px;
  background: var(--primary-color);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
}

.bbs-form__submit:hover {
  background: #adb4bd;
}

.bbs-form__submit:disabled {
  background: var(--border-color);
  cursor: not-allowed;
}