:root {
  --bg: #faf9f6;
  --fg: #223420;
  --muted: #7d8471;
  --accent: #2d4a2b;
  --border: #dedbcf;
  --code-bg: #f1efe6;
  --card-hover: #f3f1e9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a231a;
    --fg: #faf9f6;
    --muted: #a4ac86;
    --accent: #a4ac86;
    --border: #33422f;
    --code-bg: #212b1f;
    --card-hover: #232f20;
  }
}

html[data-theme="light"] {
  --bg: #faf9f6;
  --fg: #223420;
  --muted: #7d8471;
  --accent: #2d4a2b;
  --border: #dedbcf;
  --code-bg: #f1efe6;
  --card-hover: #f3f1e9;
}

html[data-theme="dark"] {
  --bg: #1a231a;
  --fg: #faf9f6;
  --muted: #a4ac86;
  --accent: #a4ac86;
  --border: #33422f;
  --code-bg: #212b1f;
  --card-hover: #232f20;
  --hero-bg: #1a231a;
  --hero-fg: #faf9f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.7;
  transition: background 0.15s ease, color 0.15s ease;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 700px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 0.5rem;
}

.site-title {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  text-decoration: none;
  color: var(--fg);
  line-height: 1.2;
}

.site-title-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.site-icon {
  display: block;
  width: 1.1em;
  height: 1.1em;
}

.site-title-main {
  font-size: 1.25rem;
  font-weight: 700;
}

.site-title-sub {
  margin-left: 1.5rem;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.theme-toggle-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  border-radius: 999px;
  width: 2.25rem;
  height: 2.25rem;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}

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

.theme-toggle-label {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
}

main {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

.home-main {
  max-width: 1100px;
}

.site-footer {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  text-align: right;
}

.home-footer {
  max-width: 1100px;
}

.footer-text {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.footer-text a {
  color: var(--muted);
  text-decoration: none;
}

.footer-text a:hover {
  text-decoration: underline;
}

.home-header {
  max-width: 1100px;
}

/* hero */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hero {
  margin-bottom: 1rem;
}

.hero-banner {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
}

@media (max-width: 640px) {
  .hero-banner {
    height: 140px;
  }
}

.hero-copy {
  text-align: center;
}

.hero-subtitle {
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.hero-cta {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.hero-cta:hover {
  opacity: 0.9;
}

/* intro */
.intro {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin: 1.5rem 0;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.intro-avatar {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--card-hover);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}

.intro-title {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.intro-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 560px) {
  .intro {
    flex-direction: column;
    text-align: center;
  }
}

/* category nav */
.category-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
  margin-bottom: 2rem;
}

.category-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  text-decoration: none;
  color: var(--fg);
  overflow: hidden;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.category-card:hover {
  background: var(--card-hover);
  transform: translateY(-2px);
}

.category-card.is-active {
  border-color: var(--accent);
  background: var(--card-hover);
}

.category-thumb {
  flex: none;
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.category-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.category-label {
  font-size: 0.92rem;
  font-weight: 600;
}

.category-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

@media (max-width: 720px) {
  .category-nav {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 560px) {
  .category-nav {
    grid-template-columns: repeat(2, 1fr);
  }
}

.list-heading {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 0.9rem;
}

/* mini apps */
.app-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.9rem;
}

.app-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.app-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  transition: background 0.15s ease;
}

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

.app-preview {
  flex: none;
  display: block;
  width: 96px;
  height: 128px;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--code-bg);
}

.app-preview iframe {
  width: 480px;
  height: 640px;
  border: 0;
  transform: scale(0.2);
  transform-origin: top left;
  pointer-events: none;
}

.app-info {
  min-width: 0;
}

.app-title {
  display: block;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  margin-bottom: 0.3rem;
}

.app-title:hover {
  color: var(--accent);
}

.app-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 480px) {
  .app-preview {
    width: 72px;
    height: 96px;
  }

  .app-preview iframe {
    transform: scale(0.15);
  }
}

/* contact */
.contact-section {
  text-align: center;
  padding: 2rem 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.contact-desc {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 380px;
  margin: 0 auto;
  text-align: left;
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.contact-cta {
  align-self: center;
  display: inline-block;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  text-decoration: none;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.contact-cta:hover {
  opacity: 0.9;
}

.contact-cta:disabled {
  opacity: 0.6;
  cursor: default;
}

.contact-status {
  margin: 0;
  font-size: 0.85rem;
  text-align: center;
}

.contact-status-success {
  color: var(--accent);
}

.contact-status-error {
  color: #c0392b;
}

/* post list — gallery grid */
.post-list {
  list-style: none;
  margin: 0 0 2.5rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.post-item {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.post-item:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.post-item-image {
  display: block;
  position: relative;
  width: 100%;
  padding-top: 75%;
  overflow: hidden;
  background: var(--code-bg);
}

.post-item-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post-item-body {
  padding: 0.9rem 1rem 1.1rem;
}

.post-item-title {
  margin: 0.5rem 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
}

.post-item-title a {
  color: var(--fg);
  text-decoration: none;
}

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

.post-item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.post-item-date {
  font-size: 0.8rem;
  color: var(--muted);
}

.post-item-category {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}

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

.post-item-excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

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

/* post detail */
.post-header {
  margin-bottom: 1.5rem;
}

.post-category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  margin-bottom: 0.6rem;
}

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

.post-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  line-height: 1.3;
}

.post-date {
  color: var(--muted);
  font-size: 0.9rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

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

.post-nav {
  display: flex;
  gap: 1rem;
  margin: 2.5rem 0 1.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.post-nav-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--fg);
  min-width: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.post-nav-link:hover {
  background: var(--card-hover);
  border-color: var(--accent);
}

.post-nav-next {
  text-align: right;
  align-items: flex-end;
}

.post-nav-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.post-nav-title {
  font-size: 0.92rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.post-list-link {
  display: block;
  text-align: center;
  margin: 0 0 1rem;
}

@media (max-width: 480px) {
  .post-nav {
    flex-direction: column;
  }

  .post-nav-next {
    text-align: left;
    align-items: flex-start;
  }
}

.post-content h1,
.post-content h2,
.post-content h3 {
}

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

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.post-content pre {
  background: var(--code-bg);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
}

.post-content code {
  background: var(--code-bg);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.post-content pre code {
  background: none;
  padding: 0;
}

.post-content blockquote {
  margin: 1rem 0;
  padding: 0.25rem 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}

.post-content th,
.post-content td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

@media (max-width: 480px) {
  .site-header {
    padding: 1.25rem 1rem 0.75rem;
  }

  main {
    padding: 0.5rem 1rem 3rem;
  }

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

  body {
    font-size: 0.95rem;
  }
}
