/* ===== リセット & ベース ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy: #1a2a4a;
  --navy-dark: #0f1e38;
  --navy-light: #2a3d6b;
  --gold: #c8a96e;
  --gold-light: #e8c98e;
  --text: #333;
  --text-light: #666;
  --text-muted: #999;
  --bg: #f8f6f0;
  --bg-card: #fff;
  --border: #ddd;
  --border-light: #eee;
  --link: #1a4080;
  --link-hover: #c8a96e;
  --danger: #c0392b;
  --success: #27ae60;
  --radius: 4px;
  --shadow: 0 1px 4px rgba(0,0,0,0.1);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.12);
}

html { font-size: 16px; }

body {
  font-family: '游明朝', 'Yu Mincho', 'YuMincho', 'ヒラギノ明朝 Pro', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

img { max-width: 100%; }

/* ===== レイアウト ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.main-layout { display: flex; gap: 24px; padding: 24px 0; }
.content-main { flex: 1; min-width: 0; }
.sidebar { width: 280px; flex-shrink: 0; }

/* ===== ヘッダー ===== */
header {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  height: 56px;
  max-width: 1100px;
  margin: 0 auto;
}

.site-logo {
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--gold);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.05em;
}
.site-logo:hover { color: var(--gold-light); text-decoration: none; }

.header-search {
  flex: 1;
  display: flex;
  gap: 8px;
  max-width: 400px;
}

.header-search input {
  flex: 1;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
}

.header-search button {
  padding: 6px 14px;
  background: var(--gold);
  color: var(--navy-dark);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: bold;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.header-nav a, .header-nav button {
  color: #fff;
  font-size: 0.9rem;
  padding: 5px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.3);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}

.header-nav a:hover, .header-nav button:hover {
  background: rgba(255,255,255,0.15);
  text-decoration: none;
  color: var(--gold-light);
}

.btn-post {
  background: var(--gold) !important;
  color: var(--navy-dark) !important;
  border-color: var(--gold) !important;
  font-weight: bold;
}

.header-nav .username { color: var(--gold); font-size: 0.85rem; }

/* ===== ナビゲーションバー ===== */
.nav-bar {
  background: var(--navy-light);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.nav-bar .container {
  display: flex;
  gap: 0;
}

.nav-bar a {
  color: rgba(255,255,255,0.85);
  padding: 10px 16px;
  font-size: 0.9rem;
  display: block;
  border-right: 1px solid rgba(255,255,255,0.1);
}
.nav-bar a:hover, .nav-bar a.active {
  background: rgba(255,255,255,0.1);
  color: var(--gold);
  text-decoration: none;
}

/* サイト統計バー */
#siteStats {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.6);
  white-space: nowrap;
}
#siteStats strong {
  color: var(--gold);
  font-size: 0.88rem;
}
@media (max-width: 600px) {
  #siteStats { display: none; }
}

/* ===== ボタン ===== */
.btn {
  display: inline-block;
  padding: 8px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
  transition: all 0.15s;
}
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-light); color: #fff; text-decoration: none; }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--navy); }
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-gold { background: var(--gold); color: var(--navy-dark); border-color: var(--gold); font-weight: bold; }
.btn-gold:hover { background: var(--gold-light); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #a93226; color: #fff; text-decoration: none; }
.btn-sm { padding: 4px 12px; font-size: 0.82rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-block { display: block; width: 100%; }

/* ===== カード ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 0.95rem;
  font-weight: bold;
}

.card-body { padding: 16px; }

/* ===== 作品カード ===== */
.work-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  transition: box-shadow 0.15s;
}
.work-card:hover { box-shadow: var(--shadow-md); }

.work-card-rank {
  width: 36px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--text-muted);
  flex-shrink: 0;
}
.work-card-rank.top1 { color: #c0a000; }
.work-card-rank.top2 { color: #888; }
.work-card-rank.top3 { color: #a06030; }

.work-card-main { flex: 1; min-width: 0; }

.work-card-title {
  font-size: 1rem;
  font-weight: bold;
  color: var(--navy);
  margin-bottom: 4px;
}
.work-card-title a { color: var(--navy); }
.work-card-title a:hover { color: var(--link-hover); }

.work-card-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.genre-badge {
  display: inline-block;
  padding: 1px 8px;
  background: var(--navy);
  color: #fff;
  border-radius: 12px;
  font-size: 0.75rem;
}

.genre-badge.詩 { background: #5b4ea8; }
.genre-badge.短歌 { background: #1a6b8a; }
.genre-badge.川柳 { background: #2e7d52; }
.genre-badge.俳句 { background: #8a4e1a; }
.genre-badge.その他 { background: #555; }

.work-excerpt {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-top: 6px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ===== セクションタイトル ===== */
.section-title {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--navy);
  border-left: 4px solid var(--gold);
  padding-left: 10px;
  margin-bottom: 14px;
}

/* ===== タブ ===== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--navy);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 8px 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  border-radius: var(--radius) var(--radius) 0 0;
  margin-right: 2px;
  transition: all 0.15s;
}
.tab-btn:hover { background: var(--border-light); }
.tab-btn.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

/* ===== フォーム ===== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.9rem; margin-bottom: 6px; font-weight: bold; color: var(--text); }
.form-label .required { color: var(--danger); margin-left: 4px; }

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 2px rgba(26,42,74,0.1); }

textarea.form-control { resize: vertical; min-height: 120px; }
select.form-control { cursor: pointer; }

.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.85rem; color: var(--danger); margin-top: 4px; }

/* ===== 評価星 ===== */
.stars {
  display: inline-flex;
  gap: 2px;
  direction: rtl;
}
.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  color: #ddd;
  transition: color 0.1s;
  padding: 0 2px;
}
.stars:hover .star-btn,
.stars .star-btn:hover ~ .star-btn { color: #f0c040; }
.star-btn.selected, .stars .star-btn:hover { color: #f0c040; }

.rating-display { color: #f0c040; font-size: 1rem; }
.rating-score { font-weight: bold; color: var(--text); }

/* ===== ページネーション ===== */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 24px;
  flex-wrap: wrap;
}
.page-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  background: #fff;
  color: var(--text);
  transition: all 0.15s;
}
.page-btn:hover { background: var(--bg); border-color: var(--navy); }
.page-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* ===== 縦書き ===== */
.vertical-text {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 1.05rem;
  line-height: 2;
  min-height: 200px;
  max-height: 600px;
  overflow-x: auto;
  padding: 20px;
  background: #fffef8;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ===== 作品本文（デフォルト：横書き・高さ自動・自然スクロール）===== */
.work-content-area {
  background: #fffef8;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin: 20px 0;
  font-size: 1.05rem;
  line-height: 2.2;
  max-width: 700px;
  width: 100%;
  overflow-x: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}

.work-content-area.vertical {
  writing-mode: vertical-rl;
  text-orientation: upright;
  max-width: none;
  width: 100%;
  height: 400px;
  overflow-x: auto;
  overflow-y: hidden;
  word-break: normal;
}

/* ===== デフォルトアバター ===== */
.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 2rem;
  font-weight: bold;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--navy);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-lg { width: 100px; height: 100px; font-size: 2.5rem; }

/* ===== サムネイル ===== */
.work-thumbnail {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
  display: block;
}

.work-thumbnail-default {
  width: 100%;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  border-radius: var(--radius) var(--radius) 0 0;
}

.work-thumbnail-default.詩 {
  background: linear-gradient(135deg, #6a0dad, #a855f7);
}
.work-thumbnail-default.短歌 {
  background: linear-gradient(135deg, #1a4080, #3b82f6);
}
.work-thumbnail-default.川柳 {
  background: linear-gradient(135deg, #14532d, #22c55e);
}
.work-thumbnail-default.俳句 {
  background: linear-gradient(135deg, #7f1d1d, #ef4444);
}
.work-thumbnail-default.その他 {
  background: linear-gradient(135deg, #374151, #9ca3af);
}

/* 作品カードにサムネイルを表示する場合のレイアウト変更 */
.work-card-with-thumb {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.work-card-with-thumb .work-card-body {
  padding: 12px 16px;
}

/* 作品詳細のサムネイル */
.work-detail-thumbnail {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: block;
}
.work-detail-thumbnail-default {
  width: 100%;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

/* ===== プロフィール ===== */
.profile-header {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.profile-info { flex: 1; }
.profile-name { font-size: 1.4rem; font-weight: bold; margin-bottom: 6px; }
.profile-stats { display: flex; gap: 20px; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; }
.profile-stats span strong { color: var(--text); font-size: 1rem; }
.profile-bio { font-size: 0.92rem; color: var(--text-light); }

/* ===== 通知 ===== */
.notification-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
}
.notification-item.unread { background: #f0f4ff; }
.notification-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* ===== フィルターバー ===== */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.filter-bar label { font-size: 0.85rem; color: var(--text-muted); }
.filter-bar select {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  background: #fff;
  cursor: pointer;
}

/* ===== フッター ===== */
footer {
  background: var(--navy-dark);
  color: rgba(255,255,255,0.7);
  padding: 32px 0 20px;
  margin-top: 60px;
  font-size: 0.88rem;
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.footer-col h3 { color: var(--gold); font-size: 0.95rem; margin-bottom: 10px; }
.footer-col a { color: rgba(255,255,255,0.6); display: block; margin-bottom: 6px; }
.footer-col a:hover { color: var(--gold-light); text-decoration: none; }
.footer-copy {
  text-align: center;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
}

/* ===== アラート ===== */
.alert {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.92rem;
}
.alert-error { background: #fde8e8; border: 1px solid #f5c6c6; color: var(--danger); }
.alert-success { background: #e8f5ee; border: 1px solid #b8dfc8; color: var(--success); }
.alert-info { background: #e8f0ff; border: 1px solid #b8c8f0; color: #2040a0; }

/* ===== ローディング ===== */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.loading::after { content: '読み込み中...'; }

/* ===== ランキング ===== */
.rank-table { width: 100%; border-collapse: collapse; }
.rank-table th {
  background: var(--navy);
  color: #fff;
  padding: 8px 12px;
  text-align: left;
  font-size: 0.88rem;
  font-weight: normal;
}
.rank-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-light); font-size: 0.92rem; }
.rank-table tr:hover td { background: #f8f6f0; }
.rank-num { font-weight: bold; text-align: center; }
.rank-num.r1 { color: #c0a000; font-size: 1.1rem; }
.rank-num.r2 { color: #888; }
.rank-num.r3 { color: #a06030; }

/* ===== マイページ ===== */
.mypage-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--navy); margin-bottom: 20px; }
.mypage-tab-btn {
  padding: 8px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  border-radius: var(--radius) var(--radius) 0 0;
  margin-right: 3px;
}
.mypage-tab-btn.active { background: var(--navy); color: #fff; }

/* ===== エディタ ===== */
.editor-wrap { display: flex; gap: 20px; }
.editor-area { flex: 1; }
.preview-area {
  flex: 1;
  background: #fffef8;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 200px;
  font-size: 1.05rem;
  line-height: 2;
  white-space: pre-wrap;
  overflow-x: hidden;
  word-break: break-word;
}
.preview-area.vertical {
  writing-mode: vertical-rl;
  text-orientation: upright;
  height: 400px;
  overflow-x: auto;
  overflow-y: hidden;
  word-break: normal;
}

/* ===== コメント ===== */
.comment-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}
.comment-avatar { width: 40px; height: 40px; font-size: 1.2rem; flex-shrink: 0; }
.comment-body { flex: 1; }
.comment-header { font-size: 0.85rem; margin-bottom: 4px; }
.comment-header strong { color: var(--navy); }
.comment-header time { color: var(--text-muted); margin-left: 8px; }
.comment-text { font-size: 0.95rem; }

/* ===== レスポンシブ ===== */
@media (max-width: 768px) {
  .main-layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .header-inner { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .header-search { max-width: 100%; order: 3; flex: 0 0 100%; }
  .header-nav { margin-left: 0; }
  .editor-wrap { flex-direction: column; }
  .nav-bar .container { overflow-x: auto; flex-wrap: nowrap; }
  .rank-table { display: block; overflow-x: auto; }
  .profile-header { flex-direction: column; align-items: center; text-align: center; }
  .profile-stats { justify-content: center; }
}

/* ===== ユーティリティ ===== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 0.85rem; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

/* ===== 通報ボタン ===== */
.btn-report {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.78rem;
  color: #9ca3af;
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn-report:hover {
  color: #ef4444;
  border-color: #fca5a5;
  background: #fef2f2;
}

/* ===== コメントメニュー ===== */
.comment-menu-wrap { position: relative; }

.comment-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  font-size: 1.1rem;
  padding: 0 4px;
  line-height: 1;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.comment-menu-btn:hover { background: #f3f4f6; color: #374151; }

.comment-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 110px;
  z-index: 50;
  overflow: hidden;
}
.comment-menu-dropdown button {
  display: block;
  width: 100%;
  padding: 8px 14px;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: #374151;
  font-family: inherit;
  transition: background 0.1s;
}
.comment-menu-dropdown button:hover { background: #f9fafb; }
.comment-menu-dropdown button:last-child { color: #ef4444; }
.comment-menu-dropdown button:last-child:hover { background: #fef2f2; }

/* ===== モーダル（通報・汎用） ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 8px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: bold;
  font-size: 1rem;
}
.modal-close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: #374151; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@media (max-width: 480px) {
  .btn-report { font-size: 0.74rem; padding: 2px 7px; }
}

/* ===== パスワード表示ボタン ===== */
.pass-toggle-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #1a2a4a;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0.7;
}
.pass-toggle-btn:hover { opacity: 1; }
