/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --text-primary: rgb(55, 53, 47);
  --text-secondary: rgba(55, 53, 47, 0.65);
  --bg-primary: #ffffff;
  --bg-secondary: #f7f6f3;
  --accent: rgba(46, 170, 220, 0.35);
  --accent-solid: rgb(46, 170, 220);
  --border: rgba(55, 53, 47, 0.09);
  --hover: rgba(55, 53, 47, 0.08);
  --content-max-width: 708px;
  --page-max-width: 900px;
  --page-padding: 96px;
  --line-height: 1.5;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, "Apple Color Emoji",
    Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
}

[data-theme="dark"] {
  --text-primary: rgba(255, 255, 255, 0.9);
  --text-secondary: rgba(255, 255, 255, 0.6);
  --bg-primary: #191919;
  --bg-secondary: #202020;
  --border: rgba(255, 255, 255, 0.13);
  --hover: rgba(255, 255, 255, 0.08);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: var(--line-height);
}

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

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

/* === Header === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding: 12px var(--page-padding);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-logo {
  font-size: 1rem;
  font-weight: 600;
}

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

.header-nav button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.header-nav button:hover {
  background: var(--hover);
}

/* === Main Content === */
.main-content {
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding: 0 var(--page-padding);
}

/* === Profile Section === */
.profile {
  padding: 40px 0 32px;
}

.profile-heading {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.profile-columns {
  display: flex;
  gap: 24px;
}

.profile-links {
  flex: 0 0 37.5%;
}

.profile-links ul {
  list-style: none;
}

.profile-links a {
  display: block;
  padding: 4px 0;
  color: var(--accent-solid);
}

.profile-links a:hover {
  text-decoration: underline;
}

.profile-bookmarks {
  flex: 1;
  color: var(--text-secondary);
}

/* === Section Headings === */
.section-heading {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 32px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* === Card Grid === */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.card {
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: background 0.15s;
  display: block;
}

.card:hover {
  background: var(--hover);
}

.card-image {
  width: 100%;
  height: 160px;
  background-size: cover;
  background-position: center;
}

.card-body {
  padding: 12px;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 6px;
}

.card-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* === Tags === */
.tag {
  display: inline-block;
  font-size: 0.6875rem;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

/* === Category List === */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 40px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 4px;
  transition: background 0.15s;
}

.category-item:hover {
  background: var(--hover);
}

.category-emoji {
  font-size: 1.25rem;
}

.category-name {
  flex: 1;
  font-size: 0.875rem;
}

.category-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* === Post Page === */
.post-cover {
  width: 100%;
  height: 30vh;
  background-size: cover;
  background-position: center 90%;
  margin: 0 calc(-1 * var(--page-padding));
  width: calc(100% + 2 * var(--page-padding));
}

.post-header {
  max-width: var(--content-max-width);
  margin: 32px auto 0;
}

.post-title {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 12px;
}

.post-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 24px;
}

.post-body {
  max-width: var(--content-max-width);
  margin: 0 auto;
}

/* === Post Body Typography === */
.post-body h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  padding-top: 0.5rem;
}

.post-body h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.post-body h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
}

.post-body p {
  margin-bottom: 0.75rem;
}

.post-body ul, .post-body ol {
  margin: 0.5rem 0 0.75rem 1.5rem;
}

.post-body li {
  margin-bottom: 0.25rem;
}

.post-body strong {
  font-weight: 600;
}

.post-body a {
  color: var(--accent-solid);
}

.post-body a:hover {
  text-decoration: underline;
}

.post-body blockquote {
  margin: 1rem 0;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent-solid);
  border-radius: 3px;
  color: var(--text-primary);
}

.post-body blockquote p:last-child {
  margin-bottom: 0;
}

.post-body img {
  display: block;
  margin: 1rem auto;
  border-radius: 2px;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.875rem;
}

.post-body th, .post-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.post-body th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.post-body code {
  font-family: "SFMono-Regular", Menlo, Consolas, "PT Mono", "Liberation Mono", Courier, monospace;
  font-size: 0.85em;
  background: var(--bg-secondary);
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

.post-body pre {
  margin: 1rem 0;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow-x: auto;
}

.post-body pre code {
  background: none;
  padding: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* === Footer === */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 60px;
}

.footer-inner {
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding: 24px var(--page-padding);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* === Responsive === */
@media (max-width: 900px) {
  :root {
    --page-padding: 48px;
  }
}

@media (max-width: 480px) {
  :root {
    --page-padding: 24px;
  }

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

  .profile-columns {
    flex-direction: column;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .post-cover {
    height: 20vh;
  }
}
