/* CSS Variables for Theme */
:root {
    --bg-color: #f6f8f7;
    /* background-light from Stitch */
    --text-color: #0f172a;
    /* Slate-900 equivalent */
    --text-color-rgb: 15, 23, 42;
    --text-secondary: #64748b;
    /* Slate-500 */
    --accent-color: #0fb382;
    /* Primary Emerald */
    --accent-color-rgb: 15, 179, 130;
    --accent-color-dark: #0a8a64;
    /* Darker accent for high-contrast text on light bg */
    --accent-light: rgba(15, 179, 130, 0.15);
    --title-color: var(--text-color);
    --border-color: #e2e8f0;
    /* Slate-200 */
    --header-bg: rgba(246, 248, 247, 0.8);
    --card-bg: #ffffff;
    --ad-bg: #f7f7f7;
    --font-sans: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', sans-serif;
    --font-serif: var(--font-sans);
    /* Use same readable font for serif roles */
    --max-width: 1400px;
    --section-gap: 80px;
    --widget-gap: 48px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

html.dark {
    --bg-color: #101010;
    /* background-dark from Stitch */
    --text-color: #f8fafc;
    /* Slate-50 */
    --text-color-rgb: 248, 250, 252;
    --text-secondary: #94a3b8;
    /* Slate-400 */
    --accent-light: rgba(15, 179, 130, 0.2);
    --title-color: var(--text-color);
    --border-color: rgba(255, 255, 255, 0.1);
    --header-bg: rgba(16, 16, 16, 0.8);
    --card-bg: #1a1a1a;
    --ad-bg: #1f1f1f;
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

/* Skip link for keyboard users (WCAG 2.4.1) */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 10000;
    padding: 10px 16px;
    background: var(--accent-color);
    color: #fff;
    border-radius: 0 0 6px 0;
    font-weight: 700;
}

.skip-link:focus {
    left: 0;
}

/* Focus-visible indicator (WCAG 2.4.7) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-sans);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-color);
}

ul {
    list-style: none;
}

/* Layout */
#container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#main {
    padding-top: 32px;
    padding-bottom: 40px;
    padding-left: 20px;
    padding-right: 20px;
}

.inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 40px;
}

.header-inner,
.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* Header */
#header {
    position: sticky;
    top: 0;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    padding: 16px 0;
    transition: background-color 0.3s;
}

@supports (backdrop-filter: blur(20px)) {
    #header {
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#header h1,
.logo-text {
    font-size: 1.25rem;
    font-weight: 850;
    letter-spacing: -0.04em;
    color: var(--text-color);
}

.logo-text a {
    color: inherit;
    text-decoration: none;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.section-title h1,
.section-title h2 {
    font-size: 1.75rem;
    font-weight: 850;
    letter-spacing: -0.03em;
    color: var(--text-color);
    margin: 0;
}

.list-head h1,
.list-head h2 {
    font-size: 1.75rem;
    font-weight: 850;
    letter-spacing: -0.03em;
    color: var(--text-color);
    margin: 0 0 24px;
}

.view-options {
    display: flex;
    gap: 8px;
    align-items: center;
}

.view-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.25;
    transition: all 0.2s;
    /* WCAG 2.5.5 touch target — visual icon stays small, hit area >= 44x44 */
    padding: 6px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.view-btn.active {
    opacity: 1;
    /* dark icon color on accent for proper contrast */
    color: #0a3a28;
    background: var(--accent-color);
    box-shadow: 0 4px 12px rgba(var(--accent-color-rgb, 15, 179, 130), 0.3);
}

.view-btn:not(.active):hover {
    opacity: 1;
    background: rgba(var(--text-color-rgb, 15, 23, 42), 0.05);
}

.view-btn span {
    font-size: 18px;
    font-weight: bold;
}

.logo-icon {
    display: none;
    /* Force remove icon container */
}

#nav-menu {
    flex: 1;
    display: flex;
    justify-content: center;
}

#nav-menu ul {
    display: flex;
    gap: 32px;
    font-weight: 500;
    font-size: 0.95rem;
}

.grid-card {
    cursor: pointer;
    transition: transform 0.2s;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-search {
    display: flex;
    align-items: center;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 4px 12px;
    border-radius: 50px;
    transition: all 0.2s;
}

.header-search:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(15, 179, 130, 0.1);
}

.header-search input {
    background: none;
    border: none;
    outline: none;
    padding: 4px 8px;
    font-size: 0.85rem;
    width: 120px;
}

.header-search button {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    opacity: 0.5;
}

#theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    /* WCAG 2.5.5 touch target — 44x44 minimum */
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--text-color);
    box-shadow: var(--shadow-sm);
}

.icon-sun {
    display: block;
}

.icon-moon {
    display: none;
}

html.dark .icon-sun {
    display: none;
}

html.dark .icon-moon {
    display: block;
}

/* Main Layout Unified Grid */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-auto-flow: row dense;
    column-gap: 60px;
    row-gap: 32px;
    /* align-items: start; REMOVED to allow sidebar to stretch */
}

/* Home Cover Logic inside Grid */
.cover-wrapper,
s_cover_group,
s_cover_rep {
    display: contents;
}

/* Global protection: Force cover modules to column 1 by default to prevent sidebar push */
.cover-wrapper>section,
.cover-wrapper>div,
s_cover_rep>* {
    grid-column: 1;
}

.hero-section {
    grid-column: 1 / -1 !important;
    position: relative;
    /* margin-bottom removed to tighten gap with content below */
    align-self: start;
}

.cover-list-section {
    grid-column: 1;
    margin-bottom: var(--section-gap);
}

/* Content Area */
.content {
    grid-column: 1;
    align-self: start;
}

/* Sidebar Alignment & Setup */
#sidebar {
    grid-column: 2;
}

.sidebar-sticky-container {}

.hero-item {
    position: relative;
    aspect-ratio: 21 / 9;
    /* From Stitch */
    border-radius: 20px;
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: flex-end;
    padding: 60px;
    color: white;
    box-shadow: var(--shadow-xl);
}

.hero-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.hero-thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    /* Combined: dark base for readability + bottom-up gradient for text legibility regardless of source image */
    background:
        linear-gradient(to right, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0.35) 60%, rgba(0, 0, 0, 0.2) 100%),
        linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.3) 55%, transparent 100%);
    z-index: 2;
}

.hero-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.7s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.hero-item:hover .hero-thumb img {
    transform: scale(1.05);
}

.hero-text {
    position: relative;
    z-index: 3;
    max-width: 800px;
    /* Hero text is always over a dark overlay, force white for guaranteed readability */
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.badge {
    display: inline-block;
    background: var(--accent-color);
    color: #101010;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 20px;
    text-shadow: none;
}

/* Hero title (h2 — was h1 before SEO refactor) */
.hero-text h2,
.hero-text .hero-title {
    /* Anchored minimum (1.5rem = 24px) ensures readability at 320px viewport */
    font-size: clamp(1.5rem, 4vw + 0.5rem, 3.5rem);
    font-weight: 850;
    line-height: 1.15;
    letter-spacing: -0.04em;
    margin-bottom: 24px;
    color: #fff;
}

.hero-text h2 a,
.hero-text .hero-title a {
    color: inherit;
    text-decoration: none;
}

.hero-text p {
    font-size: 1.15rem;
    color: rgba(255, 255, 255, 0.92);
    line-height: 1.6;
    margin-bottom: 32px;
    max-width: 600px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    /* Limit to 2 lines */
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
}

.hero-text .btn-read {
    color: #fff;
    font-weight: 600;
}

.hero-text .btn-read:hover {
    color: var(--accent-color);
}

/* Unified Grid Thumbnails */
.card-thumb,
.grid-thumb {
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16 / 10;
    background: #e2e8f0;
}

.summary-link {
    color: inherit;
    text-decoration: none;
    display: block;
}

.summary-link:hover {
    color: var(--accent-color);
}

.card-thumb img,
.grid-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.grid-card:hover .card-thumb img,
.grid-item:hover .grid-thumb img {
    transform: scale(1.05);
}

.cover-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 40px;
    margin-top: 30px;
}

@media (max-width: 768px) {
    .cover-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
}

/* (Duplicate .main-layout definition removed — see line ~279 for the canonical declaration) */

.card-body {
    padding-top: 16px;
}

.card-body .category {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    /* WCAG: use darker accent variant for sufficient contrast on light bg */
    color: var(--accent-color-dark);
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

html.dark .card-body .category {
    /* Lighter accent already passes contrast in dark mode */
    color: var(--accent-color);
}

.card-body .category a {
    color: inherit;
    text-decoration: none;
}

.card-body h3,
.card-body h4 {
    font-size: 1.25rem;
    line-height: 1.4;
    margin-bottom: 8px;
    font-weight: 700;
    color: var(--text-color);
}

.card-body h3 a,
.card-body h4 a {
    color: inherit;
    text-decoration: none;
}

.card-body p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    /* Increased to 2 for better context */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Post Grid (Home/List) */
.post-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 40px;
    margin-top: 40px;
}

@media (max-width: 768px) {
    .post-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
}

.post-grid .grid-card {
    margin-bottom: 0;
}

/* Permalink Post View */
.full-post {
    grid-column: 1 / -1;
    max-width: 900px;
    margin: 0 auto 80px;
}

.post-item.full-post .post-title {
    font-size: 3.5rem;
    line-height: 1.1;
    margin-bottom: 40px;
}

.post-item.full-post .post-content {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
    color: var(--text-color);
}

/* Sidebar */
#sidebar {
    position: sticky;
    top: 100px;
}

#sidebar h3,
#sidebar h4 {
    font-size: 0.75rem;
    margin-bottom: 20px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-color);
    opacity: 0.4;
    display: flex;
    align-items: center;
    gap: 10px;
}

#sidebar h3::after,
#sidebar h4::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
    opacity: 0.5;
}

.sidebar-widget {
    margin-bottom: var(--widget-gap);
    padding-bottom: 0;
}

.sidebar-widget ul {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-widget .search-box {
    display: flex;
    align-items: center;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 50px;
    transition: all 0.2s;
}

.sidebar-widget .search-box:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(15, 179, 130, 0.1);
}

.sidebar-widget .search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-size: 0.9rem;
    color: var(--text-color);
}

.sidebar-widget .search-box .search-btn {
    background: none;
    border: none;
    /* WCAG 2.5.5 touch target — 44x44 hit area, icon visual unchanged */
    min-width: 44px;
    min-height: 44px;
    padding: 0 8px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.5;
    transition: opacity 0.2s;
}

.sidebar-widget .search-box .search-btn:hover {
    opacity: 0.8;
}

.sidebar-widget .search-box .search-btn span {
    font-size: 1.2rem;
}



.btn-join:hover {
    filter: brightness(1.1);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 60px;
}

.pagination a,
.pagination span.num {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
    background: var(--card-bg);
    display: inline-block;
    line-height: 1.4;
}

.pagination a:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.pagination .num.selected {
    background: var(--accent-color);
    /* WCAG 1.4.3: dark text on emerald for >= 4.5:1 contrast */
    color: #0a3a28;
    font-weight: 700;
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(var(--accent-color-rgb, 15, 179, 130), 0.3);
    cursor: default;
}

/* Disabled prev/next on first/last page */
.pagination a.noMoreNew,
.pagination a.noMoreOld {
    opacity: 0.4;
    pointer-events: none;
    cursor: default;
}

/* Post Content Details */
.post-content p {
    margin-bottom: 28px;
    line-height: 1.8;
}

.post-content h2 {
    font-family: var(--font-serif);
    font-size: 2.2rem;
    margin: 60px 0 30px;
    font-weight: 700;
}

.post-content h3 {
    font-size: 1.8rem;
    margin: 40px 0 20px;
    font-weight: 700;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 16px;
    margin: 40px 0;
    box-shadow: var(--shadow-md);
}

.post-tags {
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.post-tags a {
    display: inline-block;
    padding: 3px 10px;
    background: var(--border-color);
    border-radius: 4px;
    font-size: 0.8rem;
    margin-right: 5px;
    color: var(--text-secondary);
}

/* Comments & Guestbook */
.comment-area,
.guestbook-area {
    margin-top: 60px;
    border-top: 2px solid var(--border-color);
    padding-top: 40px;
}

.comment-area h3,
.guestbook-area h2 {
    font-family: var(--font-serif);
    margin-bottom: 30px;
}

.comment-list,
.guest-comment-list {
    margin-bottom: 40px;
}

.comment-item {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.comment-item .name {
    font-weight: 700;
    display: block;
}

.comment-item .date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.comment-item .desc {
    margin-top: 10px;
}

.reply-list {
    margin-left: 30px;
    margin-top: 20px;
    border-left: 2px solid var(--accent-color);
    padding-left: 20px;
}

/* Forms */
.comment-form,
.guest-form {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.member-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.member-inputs input,
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    border-radius: 6px;
    font-family: var(--font-sans);
}

textarea {
    height: 100px;
    margin-bottom: 10px;
    resize: vertical;
}

.comment-form button,
.guest-form button {
    background: var(--accent-color);
    /* WCAG 1.4.3: dark text for sufficient contrast on emerald */
    color: #0a3a28;
    border: none;
    padding: 10px 25px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.2s;
}

.comment-form button:hover,
.guest-form button:hover {
    filter: brightness(0.95);
}

/* =========================================
   Sidebar Category Hierarchy Reconstruction
   ========================================= */

/* Reset all lists injected by Tistory under tt_category */
.tt_category,
.tt_category ul,
.tt_category li {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

/* Base anchor styling for all category links */
.tt_category a {
    display: block !important;
    padding: 8px 12px !important;
    color: var(--text-color);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.5;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
}

/* Hover effect — subtle accent background */
.tt_category a:hover {
    color: var(--accent-color);
    background: var(--accent-light);
}

/* Currently selected category */
.tt_category .filter_link_current,
.tt_category a.link_tit.filter_link_current {
    font-weight: 700;
    color: var(--accent-color);
    background: var(--accent-light);
}

/* Main Categories (Group Headers) — uniform spacing */
.tt_category .category_list > li {
    margin-bottom: 4px !important;
}

/* Sub-category container — clear visual indentation + left border */
.tt_category .category_list .sub_category_list {
    margin: 4px 0 8px 0 !important;
    padding-left: 12px !important;
    border-left: 2px solid var(--border-color);
}

/* Ensure absolutely zero margin on sub-category li wrappers */
.tt_category .category_list .sub_category_list li {
    margin: 0 !important;
    padding: 0 !important;
}

/* Specific styling for Sub-Category Links — secondary visual weight */
.tt_category .category_list .sub_category_list li a {
    font-size: 0.9em;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 6px 12px !important;
    line-height: 1.4;
}

.tt_category .category_list .sub_category_list li a:hover {
    color: var(--accent-color);
}

/* Category Post Count styling */
.tt_category .c_cnt {
    font-size: 0.8em;
    color: var(--text-secondary);
    opacity: 0.7;
    font-weight: 400;
    margin-left: 6px;
}

/* Footer */
#footer {
    padding: 40px 0;
    border-top: 1px solid var(--border-color);
    width: 100%;
    margin-top: 0;
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    opacity: 0.6;
}

/* Responsive */
/* ============================================
   Revenue (Ads) — CLS-safe + dark-mode aware
   ============================================ */
[id^="tt-adsense"],
.revenue_unit_wrap,
.sidebar-ad {
    display: block;
    width: 100%;
    margin: 32px auto;
    padding: 28px 16px 16px;
    background: var(--ad-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    max-width: 100%;
    min-height: 280px;
    clear: both;
    position: relative;
    /* overflow: hidden removed to prevent ad clipping */
    grid-column: 1 / -1;
    box-sizing: border-box;
}

/* "Advertisement" label for clear ad-content separation (AdSense policy guidance) */
.revenue_unit_wrap::before,
[id^="tt-adsense"]::before {
    content: "광고";
    display: block;
    position: absolute;
    top: 8px;
    left: 12px;
    font-size: 10px;
    line-height: 1;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Extra breathing room for in-article top ad (separates from share button) */
.ad-spacer-top {
    margin-top: 40px;
}

/* Ensure ads remain full-width in list-view as well */
.cover-grid.list-view .revenue_unit_wrap,
.cover-grid.list-view [id^="tt-adsense"] {
    grid-column: 1 / -1;
}

@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
        column-gap: 0;
    }

    #sidebar {
        display: none;
        /* Hide sidebar on small screens for simplicity, or move to bottom */
    }

    .post-title {
        font-size: 1.6rem;
    }

    .hero-item {
        height: 400px;
        padding: 30px;
    }

    .hero-text h2,
    .hero-text .hero-title {
        font-size: 2rem;
    }
}

@media (max-width: 768px) {
    [id^="tt-adsense"],
    .revenue_unit_wrap,
    .sidebar-ad {
        min-height: 250px;
        margin: 24px auto;
        padding: 24px 12px 12px;
    }

    /* First ad slot under sticky header (list_upper): keep below-fold dominance low.
       AdSense policy advises against above-the-fold ads consuming the entire first screen. */
    #main > .revenue_unit_wrap:first-child,
    #main > [id^="tt-adsense"]:first-child {
        min-height: 180px;
    }
}

#mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1001;
    /* WCAG 2.5.5 touch target — 44x44 hit area */
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

#mobile-menu-btn span {
    width: 24px;
    height: 2px;
    background: var(--text-color);
    transition: 0.3s;
}

@media (max-width: 600px) {
    #mobile-menu-btn {
        display: flex;
    }

    #nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        height: 100vh;
        background: var(--bg-color);
        padding: 100px 40px;
        transition: 0.3s;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }

    #nav-menu.active {
        right: 0;
    }

    #nav-menu ul {
        flex-direction: column;
    }

    .header-inner {
        justify-content: space-between;
    }
}

/* Tag Cloud Area */
.tag-cloud-area {
    margin-top: 60px;
    padding: 20px;
}

.tag-cloud-area h2 {
    font-family: var(--font-serif);
    font-size: 2.4rem;
    margin-bottom: 40px;
    font-weight: 700;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.tag-list li {
    list-style: none;
}

.tag-list a {
    display: inline-block;
    padding: 8px 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    font-size: 1rem;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.tag-list a:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Tistory Tag Sizes */
.tag-list a.cloud1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color-dark);
}

html.dark .tag-list a.cloud1 {
    color: var(--accent-color);
}

.tag-list a.cloud2 {
    font-size: 1.3rem;
    font-weight: 600;
}

.tag-list a.cloud3 {
    font-size: 1.1rem;
    font-weight: 500;
}

.tag-list a.cloud4 {
    font-size: 0.95rem;
}

.tag-list a.cloud5 {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Sidebar Popular Tags (compact pill list inside narrow sidebar) */
.sidebar-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* [##_tag_##]는 환경에 따라 <ul><li><a> 또는 평면 <a> 리스트로 렌더링됨 — 양쪽 정규화 */
.sidebar-tag-list ul,
.sidebar-tag-list ol {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
}

.sidebar-tag-list li {
    display: inline-flex;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sidebar-tag-list a {
    display: inline-block;
    padding: 4px 10px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--text-color);
    transition: all 0.2s;
}

.sidebar-tag-list a:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Apply Tistory cloud weight inside sidebar (smaller scale than full tag cloud area) */
.sidebar-tag-list a.cloud1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-color-dark);
}

html.dark .sidebar-tag-list a.cloud1 {
    color: var(--accent-color);
}

.sidebar-tag-list a.cloud2 {
    font-size: 0.95rem;
    font-weight: 600;
}

.sidebar-tag-list a.cloud3 {
    font-size: 0.9rem;
    font-weight: 500;
}

.sidebar-tag-list a.cloud4 {
    font-size: 0.85rem;
}

.sidebar-tag-list a.cloud5 {
    font-size: 0.8rem;
    opacity: 0.75;
}

/* List View Layout for Covers */
.cover-grid.list-view {
    grid-template-columns: 1fr;
    gap: 32px;
}

.cover-grid.list-view .grid-card {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 32px;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

.cover-grid.list-view .card-thumb {
    margin-bottom: 0;
    aspect-ratio: 16/10;
}

.cover-grid.list-view .card-body {
    padding: 0;
}

.cover-grid.list-view .card-body p {
    display: -webkit-box;
    /* Show summary in list view */
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 640px) {
    .cover-grid.list-view .grid-card {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .cover-grid.list-view .card-thumb {
        width: 100%;
    }
}

/* Premium Article Detail View */
.post-header-premium {
    margin-bottom: 40px;
}

.post-metadata-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.post-metadata-top .badge {
    background: rgba(var(--accent-color-rgb, 15, 179, 130), 0.1);
    color: var(--accent-color);
    font-size: 0.75rem;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.post-metadata-top .read-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.post-title {
    font-size: 3rem;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.04em;
    margin-bottom: 24px;
    color: var(--title-color);
}

.post-author-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.author-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.author-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(var(--accent-color-rgb, 15, 179, 130), 0.2);
    display: block;
    flex-shrink: 0;
}

.author-name {
    font-weight: 700;
    color: var(--title-color);
    margin-bottom: 2px;
}

.post-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}


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

.action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
    background: rgba(var(--accent-color-rgb, 15, 179, 130), 0.05);
}

.post-hero-image {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 48px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.post-hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Article Content Typography Refinement */
.article-content {
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--text-color);
}

.article-content p {
    margin-bottom: 24px;
}

.article-content h2 {
    font-size: 2rem;
    font-weight: 800;
    margin-top: 48px;
    margin-bottom: 20px;
    letter-spacing: -0.02em;
}

.article-content blockquote {
    margin: 40px 0;
    padding: 32px;
    background: rgba(var(--accent-color-rgb, 15, 179, 130), 0.05);
    border-left: 4px solid var(--accent-color);
    border-radius: 0 12px 12px 0;
}

.article-content blockquote p {
    font-size: 1.5rem;
    font-weight: 600;
    font-style: italic;
    margin-bottom: 0;
    color: var(--title-color);
}

.article-content ul {
    margin-bottom: 32px;
    list-style: none;
    padding-left: 0;
}

.article-content ul li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.article-content ul li::before {
    content: "check_circle";
    font-family: 'Material Symbols Outlined';
    color: var(--accent-color);
    font-size: 1.25rem;
    margin-top: 2px;
}

@media (max-width: 900px) {
    .post-title {
        font-size: 2.5rem;
    }

    .post-hero-image {
        border-radius: 12px;
    }
}