/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--tg-font);
  font-size: 16px;
  line-height: 1.75;
  color: var(--tg-text);
  background: var(--tg-bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--tg-primary); text-decoration: none; transition: color .2s ease; }
a:hover { color: var(--tg-primary-dark); }
h1, h2, h3, h4, h5, h6 { line-height: 1.35; margin: 0 0 .5em; color: var(--tg-heading); }
p { margin: 0 0 1em; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(1px,1px,1px,1px); }
.skip-link:focus { position: fixed; top: 8px; left: 8px; z-index: 9999; background: #fff; padding: 8px 14px; border-radius: 6px; width: auto; height: auto; clip: auto; }

/* ===== Buttons ===== */
.btn { display: inline-block; padding: 12px 26px; border-radius: var(--tg-radius); font-weight: 600; font-size: 15px; border: 2px solid transparent; cursor: pointer; transition: all .25s ease; }
.btn-primary { background: var(--tg-primary); color: #fff !important; }
.btn-primary:hover { background: var(--tg-primary-dark); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.12); }
.btn-ghost { background: transparent; color: var(--tg-heading) !important; border-color: rgba(128,128,128,.35); }
.btn-ghost:hover { border-color: var(--tg-primary); color: var(--tg-primary) !important; }

/* ===== Topbar ===== */
.topbar { font-size: 13px; padding: 7px 0; color: rgba(255,255,255,.85); background: var(--tg-topbar, var(--tg-primary-dark)); }
.topbar-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ===== Header ===== */
.site-header { position: sticky; top: 0; z-index: 100; background: var(--tg-header, #fff); box-shadow: 0 1px 12px rgba(0,0,0,.06); }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 72px; gap: 20px; }
.site-brand .brand-link { display: flex; align-items: center; gap: 12px; }
.brand-logo { display: flex; align-items: center; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-size: 20px; font-weight: 800; color: var(--tg-heading); letter-spacing: .2px; }
.brand-tag { font-size: 12px; color: #8a94a6; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-nav { display: flex; }
.nav-menu { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav-menu > li > a { display: block; padding: 10px 14px; border-radius: 8px; font-weight: 600; font-size: 15px; color: var(--tg-heading); }
.nav-menu > li > a:hover, .nav-menu > li.current-menu-item > a { color: var(--tg-primary); background: color-mix(in srgb, var(--tg-primary) 10%, transparent); }
.nav-toggle { display: none; background: none; border: 0; cursor: pointer; padding: 8px; }
.nav-toggle-bar { display: block; width: 22px; height: 2px; background: var(--tg-heading); margin: 5px 0; border-radius: 2px; transition: .3s; }

/* ===== Hero ===== */
.hero { position: relative; overflow: hidden; background: var(--tg-hero-bg, linear-gradient(135deg, var(--tg-primary) 0%, var(--tg-primary-dark) 100%)); color: #fff; }
.hero::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 80% 20%, rgba(255,255,255,.14) 0%, transparent 45%), radial-gradient(circle at 15% 85%, rgba(255,255,255,.10) 0%, transparent 40%); }
.hero-inner { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 40px; padding: 72px 20px; min-height: 380px; }
.hero-content { max-width: 640px; }
.hero-kicker { display: inline-block; font-size: 13px; letter-spacing: 1px; padding: 6px 14px; border-radius: 999px; background: rgba(255,255,255,.16); margin-bottom: 18px; }
.hero-title { font-size: clamp(30px, 4.5vw, 48px); color: #fff; margin-bottom: 14px; font-weight: 800; }
.hero-desc { font-size: 17px; color: rgba(255,255,255,.92); max-width: 540px; margin-bottom: 26px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.hero .btn-ghost { color: #fff !important; border-color: rgba(255,255,255,.6); }
.hero .btn-ghost:hover { border-color: #fff; }
.hero-art { position: relative; width: 240px; height: 200px; flex-shrink: 0; }
.hero-bubble { position: absolute; display: flex; align-items: center; justify-content: center; width: 74px; height: 74px; border-radius: 22px; font-size: 32px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.25); backdrop-filter: blur(6px); animation: float 5s ease-in-out infinite; }
.hero-bubble.b1 { top: 8px; left: 20px; }
.hero-bubble.b2 { top: 90px; right: 6px; animation-delay: 1.2s; }
.hero-bubble.b3 { bottom: 4px; left: 70px; animation-delay: 2.1s; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

/* ===== Sections ===== */
.section { padding: 64px 0; }
.section-head { text-align: center; margin-bottom: 36px; }
.section-head h2 { font-size: clamp(24px, 3vw, 32px); font-weight: 800; }
.section-head p { color: #8a94a6; margin: 6px 0 0; }
.section-more { font-weight: 600; font-size: 14px; }

/* ===== Category cards ===== */
.category-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.cat-card { display: flex; flex-direction: column; gap: 8px; padding: 26px 24px; background: var(--tg-card, #fff); border: 1px solid var(--tg-border, #e7ebf2); border-radius: var(--tg-radius); transition: all .25s ease; }
.cat-card:hover { transform: translateY(-4px); box-shadow: 0 12px 28px rgba(0,0,0,.08); border-color: transparent; }
.cat-icon { font-size: 30px; }
.cat-name { font-size: 18px; font-weight: 700; color: var(--tg-heading); }
.cat-desc { font-size: 13.5px; color: #8a94a6; min-height: 40px; }
.cat-more { font-size: 13px; font-weight: 600; color: var(--tg-primary); }

/* ===== Post cards ===== */
.post-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.post-card { background: var(--tg-card, #fff); border: 1px solid var(--tg-border, #e7ebf2); border-radius: var(--tg-radius); overflow: hidden; transition: all .25s ease; display: flex; flex-direction: column; }
.post-card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(0,0,0,.08); }
.post-card-media { position: relative; display: block; aspect-ratio: 16/9; overflow: hidden; background: #eef2f7; }
.post-card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.post-card:hover .post-card-media img { transform: scale(1.05); }
.post-placeholder { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; background: linear-gradient(135deg, var(--tg-primary) 0%, var(--tg-primary-dark) 100%); }
.post-card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.post-card-meta { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: #8a94a6; }
.post-cat { background: color-mix(in srgb, var(--tg-primary) 12%, transparent); color: var(--tg-primary); padding: 2px 10px; border-radius: 999px; font-weight: 600; }
.post-card-title { font-size: 17px; font-weight: 700; margin: 0; }
.post-card-title a { color: var(--tg-heading); }
.post-card-title a:hover { color: var(--tg-primary); }
.post-card-excerpt { font-size: 14px; color: #7b8595; margin: 0; line-height: 1.65; }

/* ===== Friend links ===== */
.friendlinks-section { background: var(--tg-friend-bg, #f0f4f9); }
.friend-links-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.friend-card { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; background: var(--tg-card, #fff); border: 1px dashed var(--tg-border, #d5dce6); border-radius: var(--tg-radius); transition: all .25s ease; }
.friend-card:hover { border-style: solid; border-color: var(--tg-primary); transform: translateY(-3px); box-shadow: 0 10px 22px rgba(0,0,0,.07); }
.friend-title { font-weight: 700; color: var(--tg-heading); font-size: 15px; }
.friend-desc { font-size: 12.5px; color: #8a94a6; }
.empty-tip { color: #8a94a6; text-align: center; }

/* ===== About ===== */
.about-inner { display: grid; grid-template-columns: 1.4fr 1fr; gap: 48px; align-items: center; }
.about-text h2 { font-size: 28px; font-weight: 800; }
.about-text p { color: #5f6b7c; }
.about-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat { text-align: center; padding: 24px 10px; background: var(--tg-card, #fff); border-radius: var(--tg-radius); border: 1px solid var(--tg-border, #e7ebf2); }
.stat strong { display: block; font-size: 30px; font-weight: 800; color: var(--tg-primary); }
.stat span { font-size: 13px; color: #8a94a6; }

/* ===== Archive / single ===== */
.archive-main, .single-main, .page-main { padding: 48px 0 72px; }
.archive-head { margin-bottom: 26px; }
.archive-kicker { color: var(--tg-primary); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.archive-title { font-size: clamp(26px, 3vw, 36px); font-weight: 800; }
.archive-desc { color: #7b8595; }
.archive-wrap { display: flex; gap: 36px; }
.archive-content { flex: 1; min-width: 0; }
.sub-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 28px; }
.chip { padding: 6px 16px; border-radius: 999px; background: var(--tg-card, #fff); border: 1px solid var(--tg-border, #e7ebf2); font-size: 13.5px; font-weight: 600; color: var(--tg-heading); }
.chip.active, .chip:hover { background: var(--tg-primary); color: #fff; border-color: var(--tg-primary); }
.pagination { margin-top: 40px; text-align: center; }
.pagination .nav-links { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.pagination .page-numbers { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 10px; border-radius: 10px; background: var(--tg-card, #fff); border: 1px solid var(--tg-border, #e7ebf2); color: var(--tg-heading); font-weight: 600; }
.pagination .page-numbers.current { background: var(--tg-primary); color: #fff; border-color: var(--tg-primary); }

.single-wrap, .page-wrap { display: flex; gap: 36px; }
.single-content, .page-wrap { flex: 1; min-width: 0; }
.article { background: var(--tg-card, #fff); border: 1px solid var(--tg-border, #e7ebf2); border-radius: var(--tg-radius); padding: 40px; }
.breadcrumb { font-size: 13.5px; color: #8a94a6; margin-bottom: 18px; display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb a { color: #8a94a6; }
.breadcrumb a:hover { color: var(--tg-primary); }
.article-title { font-size: clamp(26px, 3.4vw, 38px); font-weight: 800; }
.article-meta { display: flex; gap: 16px; color: #8a94a6; font-size: 13.5px; margin: 12px 0 22px; flex-wrap: wrap; }
.article-cover { margin: 0 0 26px; border-radius: var(--tg-radius); overflow: hidden; }
.article-cover img { width: 100%; }
.article-body { font-size: 16.5px; line-height: 1.9; }
.article-body h2 { font-size: 24px; margin: 1.6em 0 .6em; padding-bottom: 8px; border-bottom: 2px solid var(--tg-border, #eef1f6); }
.article-body h3 { font-size: 20px; margin: 1.4em 0 .5em; }
.article-body p { margin-bottom: 1.15em; }
.article-body ul, .article-body ol { padding-left: 1.4em; margin-bottom: 1.2em; }
.article-body li { margin-bottom: .45em; }
.article-body blockquote { margin: 1.4em 0; padding: 14px 20px; border-left: 4px solid var(--tg-primary); background: color-mix(in srgb, var(--tg-primary) 7%, transparent); border-radius: 0 10px 10px 0; color: #5f6b7c; }
.article-body figure { margin: 1.5em 0; }
.article-body figure img { border-radius: var(--tg-radius); }
.article-body figcaption { text-align: center; font-size: 13px; color: #8a94a6; margin-top: 8px; }
.article-body img { border-radius: var(--tg-radius); }
.article-body code { background: #f1f4f8; padding: 2px 8px; border-radius: 6px; font-size: 14px; }
.article-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--tg-border, #eef1f6); flex-wrap: wrap; }
.article-tags .tag-label { font-weight: 600; }
.article-tags a { margin-right: 8px; font-size: 13px; background: #f1f4f8; padding: 3px 10px; border-radius: 999px; color: #5f6b7c; }
.share-btn { display: inline-block; margin-left: 6px; padding: 5px 14px; border-radius: 999px; background: var(--tg-primary); color: #fff !important; font-size: 13px; font-weight: 600; }
.related-posts { margin-top: 40px; }
.related-posts .section-title { font-size: 24px; font-weight: 800; margin-bottom: 20px; }
.post-nav { display: flex; justify-content: space-between; gap: 20px; margin-top: 40px; }
.post-nav div { flex: 1; font-size: 14px; }
.post-nav a { display: block; background: var(--tg-card, #fff); border: 1px solid var(--tg-border, #e7ebf2); padding: 14px 18px; border-radius: var(--tg-radius); color: var(--tg-heading); font-weight: 600; }
.post-nav a:hover { border-color: var(--tg-primary); color: var(--tg-primary); }

/* ===== Sidebar ===== */
.sidebar { width: 320px; flex-shrink: 0; }
.widget { background: var(--tg-card, #fff); border: 1px solid var(--tg-border, #e7ebf2); border-radius: var(--tg-radius); padding: 22px; margin-bottom: 22px; }
.widget-title { font-size: 17px; font-weight: 800; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 2px solid var(--tg-primary); display: inline-block; }
.widget ul { list-style: none; margin: 0; padding: 0; }
.widget li { padding: 8px 0; border-bottom: 1px dashed var(--tg-border, #eef1f6); font-size: 14.5px; }
.widget li:last-child { border-bottom: 0; }
.widget li a { color: var(--tg-heading); }
.widget li a:hover { color: var(--tg-primary); }

/* ===== Footer ===== */
.site-footer { background: var(--tg-footer, #17212b); color: #b7c1cc; padding: 56px 0 0; margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1.2fr; gap: 36px; padding-bottom: 36px; }
.site-footer h4 { color: #fff; font-size: 16px; margin-bottom: 16px; }
.site-footer p { font-size: 13.5px; color: #b7c1cc; }
.footer-cats, .footer-friend-links, .footer-nav { list-style: none; margin: 0; padding: 0; }
.footer-cats li, .footer-friend-links li, .footer-nav li { margin-bottom: 8px; }
.footer-cats a, .footer-friend-links a, .footer-nav a { color: #b7c1cc; font-size: 14px; }
.footer-cats a:hover, .footer-friend-links a:hover, .footer-nav a:hover { color: #fff; }
.footer-kw { font-size: 12.5px !important; color: #8a94a6 !important; line-height: 1.8; }
.footer-bottom { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.footer-bottom p { font-size: 12.5px; color: #8a94a6; margin: 0; }
.back-to-top { position: fixed; right: 22px; bottom: 26px; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--tg-primary); color: #fff; font-size: 20px; cursor: pointer; opacity: 0; pointer-events: none; transition: all .3s ease; box-shadow: 0 8px 20px rgba(0,0,0,.18); z-index: 90; }
.back-to-top.show { opacity: 1; pointer-events: auto; }
.read-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg, var(--tg-primary), var(--tg-accent)); z-index: 300; }
.post-card, .cat-card, .friend-card { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease, box-shadow .25s ease; }
.post-card.in-view, .cat-card.in-view, .friend-card.in-view { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) { .post-card, .cat-card, .friend-card { opacity: 1; transform: none; } }

/* ===== Search / 404 / page ===== */
.search-form { display: flex; gap: 8px; margin-bottom: 28px; }
.search-form input[type="search"] { flex: 1; padding: 12px 16px; border: 1px solid var(--tg-border, #e7ebf2); border-radius: var(--tg-radius); font-size: 15px; background: var(--tg-card, #fff); }
.search-form input[type="search"]:focus { outline: 2px solid var(--tg-primary); outline-offset: -1px; }
.search-form button { padding: 12px 22px; border: 0; border-radius: var(--tg-radius); background: var(--tg-primary); color: #fff; font-weight: 600; cursor: pointer; }
.page-article { background: var(--tg-card, #fff); border: 1px solid var(--tg-border, #e7ebf2); border-radius: var(--tg-radius); padding: 40px; }
.page-title { font-size: 32px; font-weight: 800; }
.error-wrap { text-align: center; padding: 90px 20px; }
.error-code { font-size: 90px; font-weight: 800; color: var(--tg-primary); margin: 0; line-height: 1; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .post-grid, .category-grid, .friend-links-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .sidebar { display: none; }
}
@media (max-width: 768px) {
  .nav-toggle { display: block; }
  .main-nav { position: fixed; top: 0; right: -300px; width: 280px; height: 100vh; background: var(--tg-header, #fff); box-shadow: -10px 0 30px rgba(0,0,0,.12); transition: right .3s ease; padding: 70px 20px 20px; z-index: 200; }
  .main-nav.open { right: 0; }
  .nav-menu { flex-direction: column; gap: 2px; }
  .hero-inner { flex-direction: column; text-align: center; padding: 48px 20px; }
  .hero-art { display: none; }
  .hero-actions { justify-content: center; }
  .post-grid, .category-grid, .friend-links-grid { grid-template-columns: 1fr; }
  .about-inner { grid-template-columns: 1fr; }
  .about-stats { grid-template-columns: repeat(3, 1fr); }
  .single-wrap { flex-direction: column; }
  .article, .page-article { padding: 24px 18px; }
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .footer-bottom { flex-direction: column; text-align: center; }
  .post-nav { flex-direction: column; }
  .article-foot { flex-direction: column; align-items: flex-start; }
  .archive-wrap { flex-direction: column; }
}
