/* ============================================================
   Talk to Me — X(트위터) 스타일 레이아웃
   좌측 사이드바(275px) + 중앙 타임라인(600px) + 우측 위젯(350px)
   라이트/다크: body.dark-mode 로 전환 (localStorage 연동)
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #ffffff;
    --bg-widget: #f7f9f9;
    --bg-input: #eff3f4;
    --bg-hover: rgba(15, 20, 25, 0.05);
    --text: #0f1419;
    --text-secondary: #536471;
    --border: #eff3f4;
    --accent: #1d9bf0;
    --accent-hover: #1a8cd8;
    --accent-soft: rgba(29, 155, 240, 0.1);
    --like: #00ba7c;
    --like-soft: rgba(0, 186, 124, 0.1);
    --dislike: #f91880;
    --dislike-soft: rgba(249, 24, 128, 0.1);
    --header-blur-bg: rgba(255, 255, 255, 0.85);
    --error: #f4212e;
    --success: #00ba7c;
}

body.dark-mode {
    --bg: #000000;
    --bg-widget: #16181c;
    --bg-input: #202327;
    --bg-hover: rgba(231, 233, 234, 0.08);
    --text: #e7e9ea;
    --text-secondary: #71767b;
    --border: #2f3336;
    --header-blur-bg: rgba(0, 0, 0, 0.75);
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR",
                 "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    font-size: 15px;
    line-height: 1.4;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea {
    font: inherit;
    color: var(--text);
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    resize: none;
}
::placeholder { color: var(--text-secondary); }

/* ---------- 공통 요소 ---------- */

.primary-button {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    border-radius: 9999px;
    padding: 8px 20px;
    transition: background 0.15s;
}
.primary-button:hover { background: var(--accent-hover); }

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 17px;
    transition: background 0.15s;
}
.icon-button:hover { background: var(--bg-hover); }

.avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    user-select: none;
}
.anon-avatar {
    background: linear-gradient(135deg, #1d9bf0, #7856ff);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}

/* ============================================================
   전체 3단 레이아웃
   ============================================================ */

.app-shell {
    display: flex;
    justify-content: center;
    max-width: 1265px;
    margin: 0 auto;
    min-height: 100vh;
}

/* ---------- 좌측 사이드바 ---------- */

.sidebar {
    width: 275px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 4px 12px 16px;
}
.sidebar::-webkit-scrollbar { width: 0; }

.sidebar-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 28px;
    color: var(--accent);
    margin: 4px 0;
    transition: background 0.15s;
}
.sidebar-logo:hover { background: var(--accent-soft); }

.sidebar-nav { list-style: none; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 12px;
    border-radius: 9999px;
    font-size: 19px;
    width: fit-content;
    cursor: pointer;
    transition: background 0.15s;
}
.nav-link:hover { background: var(--bg-hover); }
.nav-link.active .nav-label { font-weight: 800; }

.nav-icon {
    width: 26px;
    display: inline-flex;
    justify-content: center;
    font-size: 21px;
}

.compose-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    border-radius: 9999px;
    padding: 14px 0;
    width: 90%;
    margin: 14px 0 8px;
    transition: background 0.15s;
}
.compose-btn:hover { background: var(--accent-hover); }
.compose-icon { display: none; }

.theme-row { margin-top: auto; }
.theme-row input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }

/* ---------- 중앙 타임라인 ---------- */

.main-column {
    width: 100%;
    max-width: 600px;
    min-height: 100vh;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

.main-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--header-blur-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.main-header-top {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
}
.main-header-top h1 { font-size: 20px; font-weight: 800; }

.feed-tabs { display: flex; }
.feed-tab {
    flex: 1;
    text-align: center;
    padding: 0;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    transition: background 0.15s;
}
.feed-tab:hover { background: var(--bg-hover); }
.feed-tab span {
    display: inline-block;
    position: relative;
    padding: 14px 4px;
}
.feed-tab.active { color: var(--text); font-weight: 700; }
.feed-tab.active span::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    border-radius: 9999px;
    background: var(--accent);
}

/* ---------- 글 작성 (composer) ---------- */

.composer {
    display: flex;
    gap: 12px;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border);
}
.composer-body { flex: 1; min-width: 0; }

.composer-body input[type="text"] {
    font-size: 18px;
    font-weight: 700;
    padding: 6px 0;
}
.composer-body textarea {
    font-size: 17px;
    padding: 6px 0 10px;
}
.composer-hint {
    color: var(--text-secondary);
    font-size: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.chip span {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 9999px;
    border: 1px solid var(--border);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.chip span:hover { background: var(--accent-soft); }
.chip input:checked + span {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.composer-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}
.char-counter { color: var(--text-secondary); font-size: 13px; }
.char-counter.near-limit { color: var(--error); font-weight: 700; }

.message { flex: 1; font-size: 13px; min-height: 1em; }
.message.error { color: var(--error); }
.message.success { color: var(--success); }

/* ---------- 피드 (게시물 카드) ---------- */

.feed-status {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-secondary);
}
.feed-status.error { color: var(--error); }

.post-card {
    display: flex;
    gap: 12px;
    padding: 12px 16px 6px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}
.post-card:hover { background: var(--bg-hover); }

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

.post-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: 14px;
}
.author-name { font-weight: 700; color: var(--text); }
.author-handle { color: var(--text-secondary); }
.meta-dot { padding: 0 1px; }
.post-category { color: var(--accent); }
.post-category:hover { text-decoration: underline; }

.post-text {
    margin-top: 2px;
    font-size: 15px;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

/* 테스트/플레이스홀더성 게시글은 흐리게 표시하고, 클릭하면 해제된다 */
.blurred {
    filter: blur(5px);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: filter 0.15s ease;
}
.blurred:hover {
    filter: blur(3px);
}

.post-actions {
    display: flex;
    gap: 48px;
    margin-top: 6px;
}

.action-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 6px;
    margin-left: -6px;
    border-radius: 9999px;
    transition: color 0.15s, background 0.15s;
}
.comment-action:hover { color: var(--accent); background: var(--accent-soft); }
.report-action:hover { color: var(--error); background: var(--dislike-soft); }

/* ---------- 반응 버튼 + 팔레트 ---------- */

.reaction-wrap { position: relative; display: inline-flex; }

.reaction-toggle:hover { color: var(--like); background: var(--like-soft); }
.reaction-toggle.voted { color: var(--accent); font-weight: 700; }
.reaction-emoji { font-size: 15px; line-height: 1; }

.reaction-palette {
    display: none;
    position: absolute;
    bottom: 100%;
    left: -6px;
    margin-bottom: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 9999px;
    padding: 4px 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
    white-space: nowrap;
    z-index: 30;
    gap: 2px;
}
.reaction-wrap:hover .reaction-palette,
.reaction-wrap:focus-within .reaction-palette,
.reaction-wrap.open .reaction-palette { display: flex; }

.reaction-option {
    font-size: 21px;
    line-height: 1;
    padding: 5px 6px;
    border-radius: 50%;
    transition: transform 0.12s, background 0.12s;
}
.reaction-option:hover { transform: scale(1.35) translateY(-2px); background: var(--bg-hover); }
.reaction-option.voted { background: var(--accent-soft); }

.reaction-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    padding: 8px 0 4px;
    font-size: 14px;
    color: var(--text-secondary);
}
.reaction-breakdown[hidden] { display: none; }
.detail-card .reaction-breakdown { border-bottom: 1px solid var(--border); padding: 10px 0; }
.breakdown-empty { font-size: 13px; }

/* ---------- 게시물 상세 ---------- */

.detail-card {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.detail-author {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.detail-author-meta { display: flex; flex-direction: column; }
.detail-author-meta .author-name { font-size: 15px; }
.author-handle:hover { text-decoration: underline; }

.detail-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.detail-card .md-content { font-size: 17px; }

/* ---------- 마크다운 콘텐츠 ---------- */

.md-content { line-height: 1.55; overflow-wrap: break-word; }
.md-content p { margin: 6px 0; }
.md-content p:first-child { margin-top: 0; }
.md-content p:last-child { margin-bottom: 0; }
.md-content h1 { font-size: 1.3em; font-weight: 800; margin: 10px 0 4px; }
.md-content h2 { font-size: 1.15em; font-weight: 800; margin: 10px 0 4px; }
.md-content h3 { font-size: 1.05em; font-weight: 700; margin: 8px 0 4px; }
.md-content ul { margin: 6px 0; padding-left: 22px; }
.md-content li { margin: 2px 0; }
.md-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 2px 12px;
    margin: 6px 0;
    color: var(--text-secondary);
}
.md-content code {
    background: var(--bg-input);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: ui-monospace, SFMono-Regular, Consolas, "D2Coding", monospace;
    font-size: 0.88em;
}
.md-content pre {
    background: var(--bg-input);
    border-radius: 8px;
    padding: 10px 12px;
    margin: 6px 0;
    overflow-x: auto;
}
.md-content pre code { background: none; padding: 0; }
.md-content a { color: var(--accent); }
.md-content a:hover { text-decoration: underline; }

.detail-timestamp {
    color: var(--text-secondary);
    font-size: 14px;
    padding: 14px 0 12px;
    border-bottom: 1px solid var(--border);
}

.detail-actions { padding-top: 8px; justify-content: space-around; }

.comment-composer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.comment-composer textarea { flex: 1; font-size: 16px; }
.comment-composer .primary-button { flex-shrink: 0; }

.comment-card { cursor: default; }
.comment-card:hover { background: transparent; }
.comment-card .post-actions { gap: 32px; }

/* ---------- 우측 사이드바 ---------- */

.right-sidebar {
    /* 고정(sticky) 대신 페이지와 함께 스크롤 — 창이 낮아도 위젯이 잘리지 않는다 */
    width: 350px;
    flex-shrink: 0;
    align-self: flex-start;
    padding: 8px 0 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-input);
    color: var(--text-secondary);
    border-radius: 9999px;
    padding: 11px 16px;
    font-size: 15px;
    text-align: left;
    width: 100%;
}
.search-box:hover { outline: 1px solid var(--accent); }

.widget-card {
    background: var(--bg-widget);
    border-radius: 16px;
    overflow: hidden;
}
.widget-card h2 {
    font-size: 19px;
    font-weight: 800;
    padding: 12px 16px 4px;
}

.trend-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    transition: background 0.15s;
}
.trend-item:hover { background: var(--bg-hover); }
.trend-rank, .trend-stats { font-size: 13px; color: var(--text-secondary); }
.trend-title {
    font-size: 15px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.widget-empty {
    padding: 12px 16px 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

.site-footer { padding: 0 16px; }
.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}
.footer-links a { color: var(--text-secondary); font-size: 13px; }
.footer-links a:hover { text-decoration: underline; }
.copyright { color: var(--text-secondary); font-size: 13px; margin-top: 8px; }

/* ---------- 정적 페이지 (약관 등) ---------- */

.main-column .container { padding: 16px; }
.main-column .container h2 { font-size: 20px; font-weight: 800; margin: 8px 0 12px; }
.main-column .container h3 { font-size: 16px; font-weight: 700; margin: 18px 0 6px; }
.main-column .container p { margin: 8px 0; line-height: 1.6; }
.main-column .container ul { margin: 8px 0; padding-left: 22px; }
.main-column .container li { margin: 4px 0; line-height: 1.6; }

/* ---------- 검색 모달 ---------- */

.search-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(91, 112, 131, 0.4);
    align-items: flex-start;
    justify-content: center;
}
body.dark-mode .search-modal { background: rgba(91, 112, 131, 0.3); }

.search-modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg);
    border-radius: 16px;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
    margin-top: 10vh;
    padding: 20px;
    width: min(90vw, 560px);
}
.search-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.search-input-row input {
    flex: 1;
    font-size: 17px;
    background: var(--bg-input);
    border-radius: 9999px;
    padding: 11px 18px;
}
.search-results {
    max-height: 55vh;
    overflow-y: auto;
    margin: 0 -8px;
}
.search-results .trend-item { border-radius: 12px; padding: 10px 12px; }
.close-button {
    position: absolute;
    top: -34px;
    right: 0;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
}

/* ---------- 신고 모달 ---------- */

.report-modal-content {
    background: var(--bg);
    border-radius: 16px;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
    margin-top: 18vh;
    padding: 24px;
    width: min(90vw, 400px);
}
.report-modal-content h2 { font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.report-guide { color: var(--text-secondary); font-size: 14px; margin-bottom: 12px; }

.report-reason {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.15s;
}
.report-reason:hover { background: var(--bg-hover); }
.report-reason input { width: 18px; height: 18px; accent-color: var(--accent); }

.report-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}
.secondary-button {
    border: 1px solid var(--border);
    border-radius: 9999px;
    padding: 8px 20px;
    font-weight: 700;
    transition: background 0.15s;
}
.secondary-button:hover { background: var(--bg-hover); }
#reportModal .message { margin-top: 8px; }

/* ---------- 모바일 상단/하단 바 ---------- */

.mobile-topbar, .mobile-nav { display: none; }

/* ============================================================
   반응형
   ============================================================ */

/* 우측 사이드바 축소 */
@media (max-width: 1260px) {
    .right-sidebar { width: 300px; }
}

/* 사이드바 아이콘만 표시, 우측 사이드바 숨김 */
@media (max-width: 1080px) {
    .right-sidebar { display: none; }
    .sidebar { width: 76px; align-items: center; padding: 4px 4px 16px; }
    .nav-label, .compose-label { display: none; }
    .nav-link { padding: 12px; }
    .compose-btn { width: 50px; height: 50px; padding: 0; }
    .compose-icon { display: inline; }
}

/* 모바일: 사이드바 숨기고 상단/하단 바 표시 */
@media (max-width: 680px) {
    .sidebar { display: none; }
    .main-column { border: none; max-width: 100%; padding-top: 52px; padding-bottom: 64px; }
    .main-header { top: 52px; }

    .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 20;
        height: 52px;
        padding: 0 16px;
        background: var(--header-blur-bg);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--border);
    }
    .mobile-logo {
        font-size: 17px;
        font-weight: 800;
        color: var(--accent);
    }

    .mobile-nav {
        display: flex;
        align-items: center;
        justify-content: space-around;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 20;
        height: 56px;
        background: var(--header-blur-bg);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid var(--border);
    }
    .mobile-nav .icon-button { font-size: 21px; width: 44px; height: 44px; }
    .mobile-compose {
        background: var(--accent);
        color: #fff;
    }
    .mobile-compose:hover { background: var(--accent-hover); }

    .post-actions { gap: 24px; justify-content: space-between; max-width: 320px; }
}
