/* style.css */
body {
    font-family: sans-serif;
    margin: 0;
    background-color: #f4f4f4;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

.container {
    max-width: 960px;
    width: 100%;
    margin: 20px auto;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

header {
    background-color: #333;
    color: white;
    padding: 10px 0;
    text-align: center;
    margin-bottom: 20px;
    width: 100%;
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 10px 0;
    text-align: center;
}

nav ul li {
    display: inline;
    margin: 0 10px;
}

nav a {
    color: white;
    text-decoration: none;
}

main {
    display: flex;
    width: 100%;
    margin-bottom: 20px;
    flex-grow: 1;
}

/* --- 左カラム共通スタイル --- */
.left-column,
.left-column-logged-in {
    width: 200px;
    padding-right: 20px;
    border-right: 1px solid #ccc;
    margin-right: 20px;
    flex-shrink: 0;
}

.left-column-user-profile-link-container {
    padding: 10px;
    border-bottom: 1px solid #eee;
    text-align: center;
}
.left-column-user-profile-link-container a {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #333;
}
.left-column-user-profile-link-container a:hover .left-column-username-label {
    text-decoration: underline;
    color: #0056b3;
}
img.left-column-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 8px;
    border: 1px solid #ddd;
}
span.left-column-username-label {
    font-weight: bold;
    font-size: 0.95em;
    display: block;
}

.left-column-logged-in ul { list-style: none; padding: 0; margin: 0; }
.left-column-logged-in li { padding: 0; border-bottom: 1px solid #eee; }
.left-column-logged-in li:last-child { border-bottom: none; }
.left-column-logged-in li a { text-decoration: none; color: #333; display: block; padding: 10px 10px; transition: background-color 0.2s; }
.left-column-logged-in li a:hover { background-color: #e9e9e9; }
.left-column-logged-in li.following-section-header { background-color: #f0f0f0; text-align: center; padding-top: 10px; padding-bottom: 5px; font-weight: bold; color: #333; margin: 5px 0; border-radius: 4px; border-bottom: 1px solid #ddd; }
.left-column-logged-in li.following-section-header ul#following-list-left-column { list-style: none; padding: 0; margin-top: 8px; margin-bottom: 5px; }
.left-column-logged-in li.following-section-header ul#following-list-left-column li { padding: 0; text-align: left; font-weight: normal; border-bottom: none; }
.left-column-logged-in li.following-section-header ul#following-list-left-column li a { color: #333; font-size: 0.9em; display: block; padding: 4px 15px; text-decoration: none; transition: color 0.2s, background-color 0.2s; }
.left-column-logged-in li.following-section-header ul#following-list-left-column li a:hover { color: #007bff; background-color: #e0e0e0; }

/* --- メインコンテンツエリア共通スタイル --- */
.main-content,
.main-content-logged-in,
.main-content-essay-detail,
.main-content-notifications,
.main-content-form,
.main-content-past-essays,
.main-content-profile,
div#category-content,
div#bulletinboard-content {
    flex-grow: 1;
    min-width: 0;
}

/* --- タブコンテナ共通スタイル (logged_in.html 用) --- */
.tab-container, /* index.html でも使えるように */
.tab-container-logged-in {
    margin-bottom: 20px;
    width: 100%;
}
.tab-buttons, /* index.html でも使えるように */
.tab-buttons-logged-in {
    border-bottom: 1px solid #ddd;
    margin-bottom: 15px;
    padding-bottom: 5px;
    display: flex;
    flex-wrap: wrap;
}
.tab-buttons button,
.tab-buttons-logged-in button {
    background-color: #f0f0f0;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 10px 15px;
    margin-right: 5px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: background-color 0.2s, border-bottom-color 0.2s, color 0.2s;
    color: #333;
}
.tab-buttons button:hover,
.tab-buttons-logged-in button:hover {
    background-color: #e0e0e0;
}
.tab-buttons button.active, /* index.html 用のアクティブタブスタイル */
.tab-buttons-logged-in button.active {
    background-color: #4a4a4a;
    color: #fff;
    border-bottom: 3px solid #fff; /* ログイン後と同じスタイルに統一 */
    font-weight: bold;
}
.tab-content, /* index.html でも使えるように */
.tab-content-logged-in {
    display: none;
    padding: 0 5px;
}
.tab-content.active,
.tab-content-logged-in.active {
    display: block;
}


/* --- 随筆タイムライン (logged_in.html & profile.html recent essays) --- */
#essay-timeline-logged-in, #popular-essays-list, #recent-profile-essays-list { list-style: none; padding: 0; margin: 0; }
.essay-item-logged-in { padding: 10px 0; border-bottom: 1px solid #eee; }
.essay-item-logged-in:last-child { border-bottom: none; }
.essay-title-container { background-color: #f0f0f0; padding: 10px 15px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; width: 100%; box-sizing: border-box; border-radius: 4px; }
h4.essay-title-logged-in { margin: 0; font-size: 1.2em; font-weight: bold; flex-grow: 1; margin-right: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h4.essay-title-logged-in a { color: #333; text-decoration: none; transition: color 0.2s; }
h4.essay-title-logged-in a:hover { color: #0056b3; text-decoration: underline; }
.essay-author-logged-in { font-size: 0.9em; color: #555; white-space: nowrap; flex-shrink: 0; }
.essay-author-logged-in a { color: #555; text-decoration: none; transition: color 0.2s; }
.essay-author-logged-in a:hover { color: #007bff; text-decoration: underline; }
.essay-snippet-logged-in { padding: 0 15px; margin-bottom: 12px; color: #444; line-height: 1.65; font-size: 1em; }
.essay-meta-logged-in { padding: 0 15px; font-size: 0.8em; color: #888; margin-bottom: 10px; }


/* --- 近頃の画像タブ (logged_in.html) --- */
#recent-essay-images-tab { display: flex; flex-wrap: wrap; gap: 10px; padding: 10px; }
.recent-media-item { width: calc(25% - 10px); aspect-ratio: 1 / 1; overflow: hidden; border: 1px solid #ddd; border-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); transition: transform 0.2s ease-in-out; }
.recent-media-item:hover { transform: scale(1.05); }
.recent-media-item a { display: block; width: 100%; height: 100%; }
.recent-media-item img, .recent-media-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 768px) { .recent-media-item { width: calc(33.333% - 10px); } }
@media (max-width: 480px) { .recent-media-item { width: calc(50% - 10px); } }


/* --- index.html 関連スタイル (ログイン前) --- */
#essay-timeline-index { /* ★ ID を index.html に合わせる */
    list-style: none;
    padding: 0;
    margin: 0;
}
#essay-timeline-index .essay-item-index {
    padding: 15px 10px;
    border-bottom: 1px solid #eee;
}
#essay-timeline-index .essay-item-index:last-child {
    border-bottom: none;
}
#essay-timeline-index .essay-item-index h4 {
    margin: 0 0 8px 0;
    font-size: 1.3em;
}
#essay-timeline-index .essay-item-index p {
    margin: 0 0 8px 0;
    color: #555;
    line-height: 1.6;
}
#essay-timeline-index .essay-item-index .post-meta {
    font-size: 0.8em;
    color: #777;
    text-align: right;
}
#essay-timeline-index .essay-item-index a {
    text-decoration: none;
    color: #333;
    display: block;
    transition: background-color 0.2s;
}
#essay-timeline-index .essay-item-index a:hover {
    background-color: #f9f9f9;
}
#essay-timeline-index .essay-item-index a:hover h4 {
    color: #0056b3;
}

.left-column h3 { margin-top: 0; margin-bottom: 15px; font-size: 1.5em; text-align: center; }
#login-form-aside label { display: block; margin-bottom: 5px; font-size: 0.9em; }
#login-form-aside input[type="email"], #login-form-aside input[type="password"] { width: 100%; padding: 8px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
#login-form-aside button[type="submit"] { background-color: #5cb85c; color: white; padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer; width: 100%; font-size: 1em; }
#login-form-aside button[type="submit"]:hover { background-color: #4cae4c; }
#login-form-aside hr { margin: 20px 0; }
#login-form-aside p { text-align: center; margin-top: 0; }
#login-form-aside p a { color: #007bff; text-decoration: none; }
#login-form-aside p a:hover { text-decoration: underline; }

/* =============================================== */
/* --- 掲示板ページ 及び ログイン後ホームの「にぎやかなスレ」共通スタイル --- */
/* =============================================== */
main#bulletinboard-main-container { display: flex; flex: 1; width: 100%; gap: 20px; }
#left-column-placeholder, aside#bulletinboard-categories { width: 200px; background-color: #f9f9f9; padding: 15px; border-radius: 5px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); flex-shrink: 0; align-self: flex-start; height: fit-content; }
aside#bulletinboard-categories h3 { margin-top: 0; margin-bottom: 10px; font-size: 1.2em; padding-bottom: 5px; border-bottom: 1px solid #eee; }
aside#bulletinboard-categories ul { list-style: none; padding: 0; margin: 0; }
aside#bulletinboard-categories .board-top-link a, aside#bulletinboard-categories ul li a { display: block; padding: 8px 10px; text-decoration: none; color: #333; border-bottom: 1px dotted #ccc; transition: background-color 0.2s, color 0.2s; word-wrap: break-word; }
aside#bulletinboard-categories ul li:last-child a { border-bottom: none; }
aside#bulletinboard-categories .board-top-link a { font-weight: bold; }
aside#bulletinboard-categories .board-top-link a.active-category, aside#bulletinboard-categories ul li a.active-category { background-color: #5a6268; font-weight: bold; color: #fff; }
aside#bulletinboard-categories .board-top-link a:hover, aside#bulletinboard-categories ul li a:hover { background-color: #e0e0e0; color: #000; }

div#bulletinboard-content section, div#category-content section { margin-bottom: 30px; }
div#bulletinboard-content section:last-child, div#category-content section:last-child { margin-bottom: 0; }
div#bulletinboard-content section h3, div#category-content h2, .tab-content-logged-in #active-threads-list-title { margin-top: 0; margin-bottom: 15px; padding-bottom: 8px; border-bottom: 1px solid #ddd; font-size: 1.3em; color: #333; }

ul#featured-threads-list, ul#hot-threads-list, ul#category-threads-list, ul#active-threads-list { list-style: none; padding: 0; margin: 0 0 20px 0; }
ul#category-threads-list { flex-grow: 1; }

ul#featured-threads-list li, ul#hot-threads-list li, ul#active-threads-list li.thread-list-item { padding: 10px 5px; border-bottom: 1px solid #eee; display: flex; align-items: flex-start; }
ul#category-threads-list li { padding: 10px 5px; border-bottom: 1px solid #eee; }
ul#featured-threads-list li:last-child, ul#hot-threads-list li:last-child, ul#category-threads-list li:last-child, ul#active-threads-list li.thread-list-item:last-child { border-bottom: none; }

.rank-display { width: 60px; font-weight: bold; margin-right: 10px; text-align: right; flex-shrink: 0; color: #555; display: flex; align-items: center; justify-content: flex-end; }
.rank-display .crown { margin-right: 4px; font-size: 1em; line-height: 1; }
.rank-display .crown.gold { color: gold; }

.thread-info-container { flex-grow: 1; display: block; }
.thread-info-container .thread-title-link, ul#category-threads-list li a, ul#active-threads-list li.thread-list-item .thread-title-link { text-decoration: none; color: #555; font-size: 1.1em; display: block; margin-bottom: 3px; }
.thread-info-container .thread-title-link:hover, ul#category-threads-list li a:hover, ul#active-threads-list li.thread-list-item .thread-title-link:hover { text-decoration: underline; color: #000; }
.thread-category-badge { font-size: 0.8em; background-color: #6c757d; color: white; padding: 2px 6px; border-radius: 3px; margin-right: 8px; display: inline-block; }
.thread-stats, ul#category-threads-list .thread-meta { font-size: 0.85em; color: #555; margin-top: 4px; }
ul#category-threads-list .thread-meta span { margin-right: 15px; }


.post-form { margin-top: auto; padding: 20px; background-color: #f0f0f0; border-radius: 5px; border-top: 1px solid #ddd; }
.post-form h3 { margin-top: 0; margin-bottom: 15px; padding-bottom: 8px; border-bottom: 1px solid #ccc; font-size: 1.2em; }
.post-form .input-with-counter { display: flex; align-items: center; margin-bottom: 10px; }
.post-form input[type="text"]#new-thread-title { flex-grow: 1; margin-right: 10px; padding: 8px 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box;}
.post-form .char-counter { font-size: 0.9em; color: #777; white-space: nowrap; margin-right: 10px; }
.post-form button#create-new-thread-button { flex-shrink: 0; padding: 8px 15px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; }
.post-form button#create-new-thread-button:hover { background-color: #0056b3; }

p.back-to-top-link { text-align: center; margin-top: 25px; padding-top: 15px; }

footer {
    text-align: center;
    padding: 15px 0;
    background-color: #ddd;
    border-top: 1px solid #ccc;
    margin-top: auto;
    width: 100%;
}

.clearfix::after {
    content: "";
    clear: both;
    display: table;
}

/* style.css の末尾に追記 */

/* --- index.html の非アクティブタブ用のスタイル --- */
.tab-buttons button:disabled {
    color: #aaa;
    background-color: #f5f5f5;
    cursor: not-allowed;
    border-bottom: 3px solid #eee;
}

.tab-buttons button:disabled:hover {
    background-color: #f5f5f5; /* ホバーしても色が変わらないように */
}

/* --- index.html のリンクなし随筆アイテムスタイル --- */
.essay-item-no-link {
    cursor: default; /* クリックできないことを示すカーソル */
}

.essay-item-no-link:hover {
    background-color: #fff !important; /* ホバーしても背景色が変わらないように */
}
.essay-item-no-link:hover h4 {
    color: #333 !important; /* ホバーしてもタイトル色が変わらないように */

    /* style.css の末尾に追記 */



/* --- 人気の随筆ランキング表示用スタイル --- */
.essay-item-ranked {
    display: flex; /* 王冠とタイトルコンテナを横並びにする */
    align-items: center; /* 上下中央揃え */
}

.rank-crown-container {
    width: 2em; /* 王冠用のスペースを確保 (約2文字分) */
    flex-shrink: 0; /* 王冠コンテナが縮まないように */
    text-align: center;
    font-size: 1.2em; /* 王冠のサイズをタイトルに合わせる */
}

.essay-item-ranked .essay-title-container {
    flex-grow: 1; /* 残りの幅をすべてタイトルコンテナが使う */
}