body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #fffdf6;
    color: #333;
}
header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    background: #ffffff;
}
header .brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
header img {
    width: 40px;
    height: 40px;
}
header h1 {
    font-size: 20px;
    margin: 0;
}
header .actions a {
    margin-left: 12px;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
}
.btn-login {
    color: #555;
}
.btn-register {
    background: #ffd84d;
    color: #333;
    font-weight: 600;
}
main {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    align-items: start;
}
.hero h2 {
    font-size: 36px;
    margin-bottom: 16px;
}
.hero p {
    font-size: 18px;
    line-height: 1.6;
    color: #555;
}
.hero .cta {
    margin-top: 32px;
}
.hero .cta a {
    display: inline-block;
    padding: 14px 24px;
    background: #ffd84d;
    color: #333;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
}
.visual {
    text-align: center;
}
.visual img {
    max-width: 100%;
    width: 280px;
}
footer {
    text-align: center;
    padding: 24px;
    font-size: 13px;
    color: #888;
    border-top: 1px solid #eee;
}
@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .post,
    .post-content,
    .post-header,
    .post-actions {
        text-align: left;
    }
}


/* ===== アプリページ共通：グリッド全幅 → 中央寄せ ===== */
.post-form,
.new-posts-banner,
.timeline,
.profile-page,
.dm-inbox-wrap {
    grid-column: 1 / -1;
    max-width: 600px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* ===== auth form alignment improvements ===== */
.auth-container {
    grid-column: 1 / -1;
    max-width: 420px;
    margin: 64px auto;
    padding: 0 16px;
}


.auth-card {
    padding: 32px 28px;
}


.auth-form {
    margin-top: 24px;
}


.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}


.form-group label {
    font-size: 14px;
    color: #555;
}


.form-group input {
    height: 42px;
    padding: 0 12px;
    font-size: 15px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: #fff;
}


.form-group input:focus {
    outline: none;
    border-color: #ffd84d;
    box-shadow: 0 0 0 3px rgba(255, 216, 77, 0.35);
}


.btn-primary {
    width: 100%;
    height: 44px;
    margin-top: 12px;
    border: none;
    border-radius: 8px;
    background: #ffd84d;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
}


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


.form-footer {
    margin-top: 20px;
    text-align: center;
    font-size: 14px;
}


.form-footer a {
}

#postContent {
    width: calc(100% - 4px);
    height: 5rem;
    border-radius: 5px;
}

/* ===== 投稿フォーム 画像添付 ===== */
.post-form-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.post-form-footer-icons {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.btn-image-attach {
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    padding: 4px;
    display: flex;
    align-items: center;
    border-radius: 6px;
}

.btn-image-attach:hover { color: #ffd84d; }

.post-form-footer .btn-primary {
    width: auto;
    margin-top: 0;
    padding: 0 20px;
    height: 36px;
    font-size: 14px;
}

.post-form-images {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.post-form-image-thumb {
    position: relative;
    width: 72px;
    height: 72px;
}

.post-form-image-thumb img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #eee;
    display: block;
}

.post-form-image-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== 投稿 画像グリッド ===== */
.post-images {
    display: grid;
    gap: 3px;
    margin: 8px 0;
    border-radius: 12px;
    overflow: hidden;
    max-width: 400px;
}

.post-images[data-count="1"] { grid-template-columns: 1fr; }
.post-images[data-count="2"] { grid-template-columns: 1fr 1fr; }
.post-images[data-count="3"] { grid-template-columns: 1fr 1fr; }
.post-images[data-count="3"] a:first-child { grid-row: span 2; }
.post-images[data-count="4"] { grid-template-columns: 1fr 1fr; }

.post-img {
    width: 100%;
    object-fit: cover;
    display: block;
}

/* ===== TL post ===== */

.post {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
    background: #fff;
}

.post:hover {
    background: #fafafa;
}

.post-avatar img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
}

.post-body {
    flex: 1;
    min-width: 0;
}

.post-header {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 14px;
}

.post-user {
    font-weight: bold;
    color: #222;
    text-decoration: none;
}

.post-time {
    font-size: 12px;
    color: #888;
}

.post-content {
    margin: 6px 0 10px;
    font-size: 15px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: #333;
}

.post-actions {
    display: flex;
    gap: 16px;
}

.post-action {
    background: none;
    border: none;
    padding: 0;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.post-action:hover {
    color: #111;
}

.post-action.fav:hover {
    color: #f5a623;
}

.post-action.fav.faved {
    color: #f5a623;
}

/* 自分の投稿 */
.post.me {
    background: #f9fcff;
}

.post-header {
    display: flex;
    gap: 8px;
    align-items: center;
}

.post-delete {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    color: #999;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.post-delete:hover {
    background: #fee2e2;
    color: #ef4444;
}

.post-delete svg {
    display: block;
}

.post.deleted {
    opacity: 0.5;
}

.post.deleted .post-content {
    font-style: italic;
    color: #888;
}

/* リプライ（インデントとスレッドライン） */
.post.reply {
    margin-left: 0;
    padding-left: 56px;
    position: relative;
    border-bottom: 1px solid #f0f0f0;
}

/* スレッドライン（アバターの下から伸びる線） */
.post.reply::before {
    content: "";
    position: absolute;
    left: 36px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #e6ecf0;
    z-index: 1;
}

/* 最後の要素や単発のリプライではラインを調整 */
.post.reply:last-child::before {
    height: 32px; /* アバターのあたりで止める */
}

.post-replies-section {
    border-bottom: 1px solid #eee;
    background: #fdfdfd;
}

/* サブリプライのネスト（さらに深く） */
.reply-subreplies-wrapper {
    margin-left: 20px;
    border-left: 1px solid #e6ecf0;
    background: #fafafa;
}

.reply-subreplies-wrapper .post.reply {
    padding-left: 48px;
}

.reply-subreplies-wrapper .post.reply::before {
    left: 28px;
}

.reply-subreplies-wrapper .reply-form-wrapper {
    padding-left: 16px;
}

.reply-form-wrapper {
    padding: 12px 16px 12px 56px;
}

.reply-form textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    line-height: 1.5;
}

.reply-form textarea:focus {
    outline: none;
    border-color: #ffd84d;
    box-shadow: 0 0 0 3px rgba(255, 216, 77, 0.25);
}

.reply-form-footer {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}

.btn-reply {
    background: #ffd84d;
    border: none;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-reply:hover { background: #ffcf2f; }

.btn-cancel-reply {
    background: none;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 0.85rem;
    color: #888;
    cursor: pointer;
}

.post.deleted .post-content {
    font-style: italic;
    color: #888;
}

/* ヘッダー右側 */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.welcome-text {
    font-size: 14px;
    margin: 0;
    color: #333;
}

/* ハンバーガー */
.hamburger {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: #333;
    line-height: 1;
}

.hamburger img {
    width: 24px;
    height: 24px;
}

/* ドロップダウン */
.dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,.15);
    min-width: 180px;
    padding: 8px 0;
    z-index: 100;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    background: none;
    border: none;
    padding: 10px 16px;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    color: #333;
}

.dropdown-item:hover {
    background: #f3f4f6;
}

.hidden {
    display: none;
}

/* ===== 通知 ===== */
.notif-wrap {
    position: relative;
}

.notif-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #555;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    position: relative;
    transition: background 0.15s, color 0.15s;
}

.notif-btn:hover {
    background: #f3f4f6;
    color: #111;
}

.notif-badge {
    position: absolute;
    top: 1px;
    right: 1px;
    background: #f04d4d;
    color: #fff;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 700;
    min-width: 15px;
    height: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 2px solid #fff;
    line-height: 1;
}

.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: -8px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
    box-shadow: 0 8px 30px rgba(0,0,0,.12);
    width: min(340px, calc(100vw - 24px));
    z-index: 200;
}

.notif-head {
    padding: 14px 16px 12px;
    font-size: 0.88rem;
    font-weight: 700;
    color: #111;
    border-bottom: 1px solid #f0f0f0;
    letter-spacing: 0.01em;
}

.notif-list {
    max-height: 420px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f5f5f5;
    text-decoration: none;
    color: inherit;
    transition: background 0.12s;
}

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

.notif-item:hover {
    background: #f9f9f9;
}

.notif-item--unread {
    background: #fffbf0;
}

.notif-item--unread:hover {
    background: #fff5d6;
}

/* アバター＋タイプチップ */
.notif-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.notif-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.notif-type-chip {
    position: absolute;
    bottom: -3px;
    right: -5px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    color: #fff;
}

.notif-type-chip--reply  { background: #3b82f6; }
.notif-type-chip--follow { background: #a855f7; }
.notif-type-chip--dm     { background: #22c55e; }

.notif-body {
    flex: 1;
    min-width: 0;
    padding-top: 2px;
}

.notif-text {
    font-size: 0.86rem;
    line-height: 1.45;
    color: #333;
}

.notif-time {
    font-size: 0.76rem;
    color: #bbb;
    margin-top: 4px;
}

.notif-empty,
.notif-loading {
    padding: 36px 16px;
    text-align: center;
    color: #bbb;
    font-size: 0.86rem;
}

/* ===== 新着バナー ===== */
.new-posts-banner {
    display: block;
    margin: 0 auto 10px;
    width: fit-content;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 7px 18px;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(0,0,0,.18);
    transition: background 0.15s, transform 0.1s;
}

.new-posts-banner:hover {
    background: #111;
    transform: translateY(-1px);
}

.new-posts-banner.hidden {
    display: none;
}

/* ===== フォローボタン / プロフィール統計 ===== */
.btn-follow {
    font-size: 0.8rem;
    padding: 4px 14px;
    border-radius: 20px;
    border: 1px solid #ffd84d;
    background: #ffd84d;
    color: #333;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-follow.following {
    background: #fff;
    color: #555;
    border-color: #ddd;
}

.btn-follow:hover:not(.following) {
    background: #ffcf2f;
}

.btn-follow:disabled {
    opacity: 0.6;
    cursor: default;
}

.profile-stats {
    display: flex;
    gap: 16px;
    margin-top: 10px;
    font-size: 0.85rem;
    color: #555;
}

.profile-stat-link {
    color: #555;
    text-decoration: none;
}

.profile-stat-link:hover {
    text-decoration: underline;
}

/* ===== フォロー/フォロワーリスト ===== */
.follow-list-page {
    grid-column: 1 / -1;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    background: #fff;
}

.follow-list-header {
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
}

.follow-list-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px 8px;
}

.follow-list-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: #444;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.15s;
}

.follow-list-back:hover {
    background: #f3f4f6;
    color: #111;
}

.follow-list-title {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.follow-list-owner-name {
    font-size: 1rem;
    font-weight: 700;
    color: #111;
    line-height: 1.2;
}

.follow-list-subtitle {
    font-size: 0.78rem;
    color: #999;
}

.follow-list-tabs {
    display: flex;
}

.follow-list-tab {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    font-size: 0.88rem;
    font-weight: 500;
    color: #999;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, background 0.12s;
}

.follow-list-tab:hover {
    color: #333;
    background: #f9f9f9;
}

.follow-list-tab.active {
    color: #111;
    font-weight: 700;
    border-bottom-color: #ffd84d;
}

.follow-list-item {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #f5f5f5;
    text-decoration: none;
    color: inherit;
    transition: background 0.12s;
}

.follow-list-item:last-child {
    border-bottom: none;
}

.follow-list-item:hover {
    background: #fafafa;
}

.follow-list-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.follow-list-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #222;
    line-height: 1.3;
}

.follow-list-bio {
    font-size: 0.84rem;
    color: #777;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.follow-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 56px 20px;
    color: #ccc;
}

.follow-list-empty p {
    margin: 0;
    font-size: 0.92rem;
    color: #aaa;
}

/* ===== DM ===== */

/* ─── body.dm-chat-layout: チャット画面用にmainをリセット ─── */
body.dm-chat-layout main {
    padding: 0;
    display: block;
    max-width: 600px;
    height: calc(100vh - 73px);
    overflow: hidden;
}

/* ─── 受信箱 ─── */
.dm-inbox-wrap {
    background: #fff;
}

.dm-inbox-head {
    padding: 16px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.dm-inbox-head-title {
    font-size: 1rem;
    font-weight: 700;
    color: #222;
}

.dm-conv {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    color: inherit;
}

.dm-conv:hover { background: #fafafa; }

.dm-conv--unread { background: #fffde7; }

.dm-conv__avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.dm-conv__avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.dm-conv__badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ffd84d;
    border: 2px solid #fff;
}

.dm-conv__body {
    flex: 1;
    min-width: 0;
}

.dm-conv__top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.dm-conv__name {
    font-size: 0.9rem;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-conv__name--bold { font-weight: 700; }

.dm-conv__time {
    font-size: 0.75rem;
    color: #aaa;
    white-space: nowrap;
    flex-shrink: 0;
}

.dm-conv__preview {
    font-size: 0.83rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.dm-conv__preview--bold { color: #333; font-weight: 600; }

.dm-conv__me { color: #aaa; }

.dm-inbox-empty {
    padding: 60px 20px;
    text-align: center;
    color: #aaa;
    line-height: 1.7;
}

.dm-inbox-empty__icon {
    margin-bottom: 12px;
    color: #ccc;
}

.dm-inbox-empty__sub {
    font-size: 0.83rem;
    color: #bbb;
    margin-top: 4px;
}

/* ─── 会話画面 ─── */
.dm-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fff;
}

.dm-chat__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    background: #fff;
}

.dm-chat__back {
    color: #555;
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.dm-chat__back:hover { color: #111; }

.dm-chat__partner {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #222;
    font-weight: 600;
    font-size: 0.95rem;
    min-width: 0;
}

.dm-chat__partner-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.dm-chat__partner-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dm-date-sep {
    text-align: center;
    font-size: 0.75rem;
    color: #aaa;
    margin: 12px 0 8px;
}

.dm-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 2px;
}

.dm-msg--mine  { flex-direction: row-reverse; }
.dm-msg--theirs { flex-direction: row; }

.dm-msg__avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.dm-msg__bubble {
    max-width: 70%;
    display: flex;
    flex-direction: column;
}

.dm-msg--mine .dm-msg__bubble  { align-items: flex-end; }
.dm-msg--theirs .dm-msg__bubble { align-items: flex-start; }

.dm-msg__text {
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.dm-msg--mine .dm-msg__text {
    background: #ffd84d;
    border-bottom-right-radius: 4px;
}

.dm-msg--theirs .dm-msg__text {
    background: #f0f0f0;
    border-bottom-left-radius: 4px;
}

.dm-msg__time {
    font-size: 0.72rem;
    color: #999;
    margin-top: 3px;
    padding: 0 4px;
}

.dm-chat__footer {
    border-top: 1px solid #eee;
    padding: 10px 12px;
    flex-shrink: 0;
    background: #fff;
}

.dm-chat__form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.dm-chat__input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    line-height: 1.5;
    box-sizing: border-box;
    overflow-y: hidden;
}

.dm-chat__input:focus {
    outline: none;
    border-color: #ffd84d;
    box-shadow: 0 0 0 3px rgba(255,216,77,.25);
}

.dm-chat__send {
    background: #ffd84d;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    color: #333;
}

.dm-chat__send:hover { background: #ffcf2f; }

.dm-chat__error {
    color: #c00;
    font-size: 0.82rem;
    margin-top: 6px;
    padding-left: 14px;
}

/* プロフィールのDMボタン */
.btn-dm {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    padding: 4px 14px;
    border-radius: 20px;
    border: 1px solid #ddd;
    background: #fff;
    color: #555;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.btn-dm:hover {
    background: #f5f5f5;
}
