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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  color: #333;
  background: #f5f5f5;
  margin: 0;
  padding: 0;
}

.container {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1rem;
}

h1 {
  font-size: 1.5rem;
  border-bottom: 2px solid #333;
  padding-bottom: 0.5rem;
}

/* コメント内リンク */
.comment-item-body a {
  color: #6b9fd4;
  text-decoration: none;
}

.comment-item-body a:hover {
  color: #4a7fb5;
  text-decoration: underline;
}

/* コメント一覧 */
#comment-list {
  margin-bottom: 2rem;
}

.comment-empty {
  color: #888;
  font-style: italic;
}

/* コメントアイテム */
.comment-item {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.comment-item[data-status="close"] {
  opacity: 0.6;
}

.comment-item[data-status="close"] {
  border-left: 3px solid #d9534f;
}

.comment-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.comment-item-title {
  font-size: 1rem;
  margin: 0;
}

.comment-status-badge {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  font-weight: bold;
}

.status-close {
  background: #f2dede;
  color: #a94442;
}

.comment-item-content {
  margin-left: 11px;
  padding-left: 19px;
  border-left: 2px solid #ddd;
}

.comment-item-body {
  margin-bottom: 0.5rem;
}

.comment-item-header .comment-item-name {
  font-size: 0.85rem;
  color: #666;
}

.comment-item-header .comment-item-date {
  font-size: 0.85rem;
  color: #999;
}

.comment-item-url {
  color: #337ab7;
}

/* アバター */
.comment-avatar {
  border-radius: 50%;
  vertical-align: middle;
  flex-shrink: 0;
}

.comment-item-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* アイコンボタン */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  color: #999;
  font-size: 0;
}

.btn-icon:hover {
  background: #f0f0f0;
  color: #555;
}

.btn-icon .material-symbols-outlined {
  font-size: 20px;
}

.btn-icon-danger:hover {
  color: #d9534f;
  background: #fdf2f2;
}

/* フォーム */
form {
  padding: 0;
}

form h3 {
  margin-top: 0;
  font-size: 1.1rem;
}

.form-group {
  margin-bottom: 0.5rem;
}

/* 投稿フォームと一覧の間 */
#comment-form-wrapper {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
}

.form-group textarea {
  field-sizing: content;
  max-height: 20em;
  overflow-y: auto;
}

/* ルートコメント投稿フォーム */
#comment-form .form-group textarea {
  min-height: calc(5lh + 1rem + 2px);
}

/* 返信・編集フォーム */
.reply-form .form-group textarea {
  min-height: calc(2lh + 1rem + 2px);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #66afe9;
  box-shadow: 0 0 0 2px rgba(102, 175, 233, 0.3);
}

.required {
  color: #d9534f;
}

.error-text {
  color: #d9534f;
  font-size: 0.85rem;
  margin: 0.25rem 0 0;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
}

/* ボタン */
.btn {
  display: inline-block;
  padding: 0.4rem 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
}

.btn:hover {
  background: #e6e6e6;
}

.btn-primary {
  background: #337ab7;
  border-color: #337ab7;
  color: #fff;
}

.btn-primary:hover {
  background: #286090;
}

.btn-sm {
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
}

.btn-danger {
  color: #d9534f;
  border-color: #d9534f;
}

.btn-danger:hover {
  background: #d9534f;
  color: #fff;
}

/* 編集中のコメント */
.comment-item-editing {
  border-color: #66afe9;
  border-width: 2px;
}

/* 成功メッセージ */
.comment-success {
  background: #dff0d8;
  border: 1px solid #d6e9c6;
  color: #3c763d;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

/* NGワード通知 */
.comment-notice-ng {
  background: #fcf8e3;
  border: 1px solid #faebcc;
  color: #8a6d3b;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* ページヘッダー */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-header h1 {
  border-bottom: none;
  padding-bottom: 0;
}

/* ユーザー切替 */
.user-switcher {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.user-switcher-label {
  font-size: 0.85rem;
  color: #666;
}

.btn-admin-user {
  border-color: #d9534f;
  color: #d9534f;
}

.btn-admin-user.btn-active {
  background: #d9534f;
  border-color: #d9534f;
  color: #fff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.current-user {
  font-size: 0.85rem;
  color: #555;
}

.admin-notice {
  background: #d9edf7;
  border: 1px solid #bce8f1;
  color: #31708f;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* コメントリストヘッダー */
.comment-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.comment-count {
  font-weight: 600;
  color: #555;
}

.comment-display-toggle {
  display: flex;
  gap: 0.25rem;
}

.btn-active {
  background: #337ab7;
  border-color: #337ab7;
  color: #fff;
}

.btn-active:hover {
  background: #286090;
  color: #fff;
}

/* スレッド表示 - 子コメント */
.comment-children {
  margin-top: 0.5rem;
}

.comment-children .comment-item {
  margin-bottom: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0.75rem 0;
  border-bottom: 1px solid #eee;
}

.comment-children .comment-item:last-child {
  border-bottom: none;
}

/* 返信先表示 */
.comment-item-reply-to {
  font-size: 0.8rem;
  color: #999;
}

/* 返信読み込みボタン */
.comment-children-placeholder {
  margin-top: 0.5rem;
}

.btn-load-replies {
  color: #337ab7;
  border-color: transparent;
  background: transparent;
  padding: 0.3rem 0;
  font-size: 0.85rem;
}

.btn-load-replies:hover {
  background: transparent;
  text-decoration: underline;
  color: #286090;
}

/* 返信フォーム */
.reply-form {
  margin-top: 0.75rem;
  padding: 1rem;
  background: #f9f9f9;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
}

.reply-form h4 {
  margin-top: 0;
  font-size: 1rem;
}

.reply-form .form-group {
  margin-bottom: 0.75rem;
}

/* もっとコメントを表示 */
.more-comments-placeholder {
  text-align: center;
  margin: 1rem 0;
}

.btn-load-more {
  color: #337ab7;
  border-color: transparent;
  background: transparent;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-load-more:hover {
  background: transparent;
  text-decoration: underline;
  color: #286090;
}

/* いいねボタン */
.like-button-wrapper {
  display: inline-flex;
  align-items: center;
}

.btn-like {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  color: #999;
  font-size: 0;
}

.btn-like:hover {
  background: #fdf2f2;
  color: #e0245e;
}

.btn-like.liked {
  color: #e0245e;
}

.btn-like .material-symbols-outlined {
  font-size: 20px;
  font-variation-settings: 'FILL' 0;
}

.btn-like.liked .material-symbols-outlined {
  font-variation-settings: 'FILL' 1;
}

.like-count {
  font-size: 0.8rem;
  color: inherit;
}

/* htmx ローディング */
.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}
