:root {
  --accent: #6f42c1;
  --accent-dark: #553098;
  --accent-soft: #f3effb;
  --warm-icon: #d9822b;
  --text: #1f2328;
  --text-muted: #5c6470;
  --bg: #ffffff;
  --surface: #f7f8fa;
  --border: #e6e8ec;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.08);
  --max-width: 1280px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(0.975rem, 0.94rem + 0.18vw, 1.05rem);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--accent);
  text-decoration: none;
}

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

.site-main {
  flex: 1 0 auto;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: 1rem;
}

@media (min-width: 768px) {
  .container {
    padding-inline: 1.5rem;
  }
}

/* ===== Tier 1: Sticky Top Bar ===== */
.site-topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding-block: 0.45rem;
  gap: 0.75rem;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.brand-logo {
  height: 36px;
  width: auto;
  max-width: 155px;
  object-fit: contain;
  display: block;
}

@media (min-width: 768px) {
  .brand-logo {
    height: 42px;
    max-width: 175px;
  }
}

.brand-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.nav-toggle:hover {
  background: var(--surface);
}

.topbar-menu {
  display: none;
  width: 100%;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 0.65rem;
  padding-bottom: 0.35rem;
  border-top: 1px solid var(--border);
}

.topbar-menu.is-open {
  display: flex;
}

.primary-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  font-size: 0.95rem;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover,
.nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.search-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
}

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  padding: 0 0.9rem;
  border: 1px solid #d0d5dd;
  border-radius: 999px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(111, 66, 193, 0.15);
}

.search-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  height: 38px;
  padding: 0 0.95rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.search-btn:hover {
  background: var(--accent-dark);
}

@media (min-width: 768px) {
  .nav-toggle {
    display: none;
  }

  .topbar-inner {
    flex-wrap: nowrap;
  }

  .topbar-menu {
    display: flex;
    width: auto;
    flex: 1 1 auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-top: 0;
    padding: 0;
    margin-left: 1rem;
  }

  .primary-nav {
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
  }

  .search-form {
    width: auto;
    min-width: 220px;
    max-width: 270px;
  }
}

/* ===== Tier 2: Category Pills Bar ===== */
.category-bar {
  background: #f8f7fc;
  border-bottom: 1px solid #ece8f6;
}

.category-pills {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding-block: 0.55rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.category-pills::-webkit-scrollbar {
  display: none;
}

@media (min-width: 1024px) {
  .category-pills {
    flex-wrap: wrap;
    justify-content: center;
    overflow-x: visible;
    padding-block: 0.65rem;
  }
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid #dfd8f2;
  background: #ffffff;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cat-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.cat-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* ===== Homepage Hero (Mobile-first, compact above the fold) ===== */
.hero-section {
  padding: 1.15rem 0 0.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #faf9fd 100%);
}

@media (min-width: 768px) {
  .hero-section {
    padding: 1.75rem 0 1.4rem;
  }
}

.hero-inner {
  max-width: 820px;
  margin-inline: auto;
}

.hero-tagline {
  margin: 0 0 0.5rem;
  font-size: clamp(1.3rem, 2.8vw, 1.95rem);
  font-weight: 750;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--text);
  text-align: center;
}

.hero-lead,
.hero-rest,
.hero-bio-desktop {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.96rem;
  line-height: 1.6;
}

.hero-bio-desktop {
  display: none;
}

.bio-details {
  margin-top: 0.45rem;
}

.bio-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  padding: 0.25rem 0;
}

.bio-summary::-webkit-details-marker {
  display: none;
}

.bio-summary::after {
  content: "▾";
  font-size: 0.85em;
  transition: transform 0.15s ease;
}

.bio-details[open] .bio-summary::after {
  transform: rotate(180deg);
}

.bio-details .hero-rest {
  margin-top: 0.5rem;
  padding-bottom: 0.5rem;
}

@media (min-width: 768px) {
  .hero-bio-mobile {
    display: none;
  }

  .hero-bio-desktop {
    display: block;
    max-width: 74ch;
    margin-inline: auto;
    font-size: 1rem;
    line-height: 1.65;
    text-align: left;
  }
}

/* ===== Archive Header (Category / Tag / Search) ===== */
.archive-header {
  padding: 1.5rem 0 1rem;
  border-bottom: 1px solid var(--border);
  background: #faf9fd;
}

.archive-title {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  font-weight: 750;
  line-height: 1.25;
}

.archive-desc {
  margin: 0.5rem 0 0;
  max-width: 74ch;
  color: var(--text-muted);
  font-size: 0.98rem;
}

/* ===== Project Card Grid ===== */
.projects-section {
  padding: 1.25rem 0 3rem;
}

@media (min-width: 768px) {
  .projects-section {
    padding: 1.75rem 0 3.5rem;
  }
}

.section-heading {
  margin: 0 0 1rem;
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-weight: 700;
}

.empty-state {
  color: var(--text-muted);
  padding: 2rem 0;
}

.project-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 640px) {
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.35rem;
  }
}

@media (min-width: 1024px) {
  .project-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
  }
}

.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.project-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: #d6cceb;
}

.card-media {
  aspect-ratio: 4 / 3;
  background: var(--surface);
  overflow: hidden;
}

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

.card-body {
  flex: 1 1 auto;
  padding: 1rem 1.1rem 0.75rem;
}

.card-title {
  margin: 0 0 0.4rem;
  font-size: 1.12rem;
  font-weight: 650;
  line-height: 1.35;
}

.card-link {
  color: var(--text);
}

.card-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

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

.card-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.card-footer {
  padding: 0.65rem 1.1rem;
  border-top: 1px solid var(--border);
  background: #fcfcfd;
}

.card-cat {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.meta-icon {
  color: var(--warm-icon);
  flex-shrink: 0;
}

/* ===== Pagination ===== */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.page-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1.15rem;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background-color 0.15s ease;
}

.page-btn:hover {
  background: var(--accent-dark);
  color: #ffffff;
}

/* ===== Article / Page Layout ===== */
.page-wrap {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
}

@media (min-width: 768px) {
  .page-wrap {
    padding-top: 2.25rem;
    padding-bottom: 3.5rem;
  }
}

.article-header {
  max-width: 820px;
  margin: 0 auto 1.75rem;
  text-align: center;
}

.article-title {
  margin: 0 0 0.6rem;
  font-size: clamp(1.6rem, 3.2vw, 2.45rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.015em;
  overflow-wrap: break-word;
}

.article-subtitle {
  margin: 0 0 0.85rem;
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  color: var(--text-muted);
  line-height: 1.55;
}

.article-meta {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.9rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
}

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

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.25rem;
}

.article-layout.is-static {
  max-width: 820px;
  margin-inline: auto;
}

@media (min-width: 1024px) {
  .article-layout:not(.is-static) {
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 2.5rem;
    align-items: start;
  }
}

.article-main {
  min-width: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.article-cover {
  margin: 0 0 1.5rem;
  text-align: center;
}

.article-cover-img {
  display: block;
  margin-inline: auto;
  max-width: 100%;
  max-height: 72vh;
  width: auto;
  height: auto;
  border-radius: var(--radius);
  object-fit: contain;
}

.article-caption {
  margin-top: 0.5rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ===== Pasted Google Docs / TinyMCE Responsive Normalization ===== */
.inner {
  min-width: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
  font-size: clamp(1rem, 0.96rem + 0.18vw, 1.075rem);
  line-height: 1.72;
}

.inner span[style*="width"],
.inner span[style*="height"] {
  display: block !important;
  width: auto !important;
  max-width: 100% !important;
  height: auto !important;
  overflow: visible !important;
  margin: 1rem auto !important;
}

.inner img {
  display: block;
  width: auto !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: 82vh;
  margin: 1.1rem auto;
  border-radius: 8px;
}

.inner [style*="font-size: 8pt"],
.inner [style*="font-size: 9pt"],
.inner [style*="font-size: 10pt"],
.inner [style*="font-size: 10.5pt"],
.inner [style*="font-size: 11pt"],
.inner [style*="font-size: 11.5pt"],
.inner [style*="font-size: 12pt"],
.inner [style*="font-size: 12px"] {
  font-size: inherit !important;
}

.inner p,
.inner li {
  line-height: 1.68 !important;
}

.inner p {
  margin: 0 0 0.95rem !important;
}

.inner p[style*="background-color: #ffffff"],
.inner p[style*="background-color: #fafafa"],
.inner span[style*="background-color: #ffffff"],
.inner span[style*="background-color: #fafafa"] {
  background-color: transparent !important;
}

.inner table {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 1.25rem 0;
}

.inner table th,
.inner table td {
  padding: 0.45rem 0.65rem !important;
  vertical-align: top;
}

.inner iframe {
  max-width: 100%;
  border: 0;
  border-radius: 8px;
}

.inner iframe:not([style*="position: absolute"]):not([style*="transform"]) {
  width: 100% !important;
  height: clamp(420px, 70vh, 800px) !important;
}

.inner pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 0.9rem 1rem;
  border-radius: 8px;
  background: var(--surface);
}

@media (max-width: 767.98px) {
  .inner p,
  .inner div:not([style*="position: relative"]),
  .inner li {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    text-indent: 0 !important;
    text-align: left !important;
  }

  .inner ul,
  .inner ol {
    padding-left: 1.25rem !important;
  }
}

/* ===== Tags ===== */
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.84rem;
  font-weight: 500;
}

.tag-pill:hover {
  background: var(--accent);
  color: #ffffff;
}

/* ===== Sidebar ("More Projects") ===== */
.sidebar-heading {
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.15rem;
  font-weight: 700;
}

.sidebar-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 640px) and (max-width: 1023.98px) {
  .sidebar-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.sidebar-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.55rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.sidebar-card:hover {
  background: var(--accent-soft);
  border-color: #dfd8f2;
}

.sidebar-thumb {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.sidebar-link {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 550;
  line-height: 1.35;
}

.sidebar-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

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

@media (min-width: 1024px) {
  .sidebar-sticky {
    position: sticky;
    top: 78px;
  }
}

/* ===== Footer ===== */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  padding: 1.75rem 0;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: center;
}

.footer-brand {
  font-size: 0.98rem;
  color: var(--text);
}

.footer-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.86rem;
  color: var(--text-muted);
}

@media (min-width: 640px) {
  .footer-bottom {
    flex-direction: row;
    justify-content: space-between;
  }
}

.footer-admin {
  color: var(--accent);
  font-weight: 500;
}

/* ===== 404 Error Page ===== */
.error-wrap {
  max-width: 560px;
  margin-inline: auto;
  padding-block: 3rem;
  text-align: center;
}

.error-img {
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 0 auto 1.25rem;
  display: block;
}

.error-title {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
}

.error-desc {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
}
