:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --border: #eaeaea;
  --accent: #2b6cb0;
  --tag-bg: #f2f2f2;
  --tag-text: #444;
}

/* Dark theme: follows the system unless the user explicitly selects light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1e20;
    --text: #dedede;
    --text-muted: #8a8a8a;
    --border: #2e2f31;
    --accent: #6fa8dc;
    --tag-bg: #2a2b2d;
    --tag-text: #bbb;
  }
}

/* Explicit dark mode always wins over the system preference. */
:root[data-theme="dark"] {
  --bg: #1d1e20;
  --text: #dedede;
  --text-muted: #8a8a8a;
  --border: #2e2f31;
  --accent: #6fa8dc;
  --tag-bg: #2a2b2d;
  --tag-text: #bbb;
}

/* Base */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header & navigation */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.6rem;
}

.site-title {
  color: var(--text);
  font-family: "Noto Sans Buginese", "Segoe UI Historic", sans-serif;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.site-title:hover {
  opacity: 0.75;
  text-decoration: none;
}

nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

nav a {
  color: var(--text);
  font-size: 0.95rem;
}

nav a.active {
  color: var(--accent);
}

#theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}


#theme-toggle svg {
  width: 16px;
  height: 16px;
}

/* Layout & page state */
main {
  min-height: 60vh;
}

section.page {
  display: none;
  padding: 2.25rem 0 3rem;
}

section.page.active,
.sub-view.active {
  display: block;
}

.sub-view {
  display: none;
}

/* Home */
.home-hero h1 {
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

.home-hero p {
  margin: 0 0 0.9rem;
}

.role {
  font-weight: bold;
  font-style: italic;
}

.social-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin: 1.1rem 0 0;
}

.social-row a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.9rem;
}

.social-row a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.social-row a svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* Section headings & metadata */
h2.section-title {
  margin: 0 0 1.1rem;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.page-intro {
  margin: -0.6rem 0 1.4rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.meta {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.meta span:not(:last-child)::after {
  content: " · ";
}

/* Latest content on home */
.latest-section {
  margin-top: 2.2rem;
  padding-top: 1.8rem;
  border-top: 1px solid var(--border);
}

.latest-block {
  margin-bottom: 1.8rem;
}

.latest-block:last-child {
  margin-bottom: 0;
}

.latest-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.7rem;
}

.latest-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.latest-head a {
  font-size: 0.82rem;
}

/* List items */
.article-item,
.timeline-item,
.project-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 1.1rem 0;
  margin-bottom: 24px;
}

.article-item,
.project-item {
  border-bottom: 1px solid var(--border);
}

.article-item:first-child,
.project-item:first-child {
  padding-top: 0;
}

.item-body {
  flex: 1;
  min-width: 0;
}

.preview-image {
  width: 120px;
  height: 90px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 6px;
}

.article-item h3,
.timeline-item h3,
.project-item h3 {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.article-item h3 a,
.timeline-item h3 a,
.project-item h3 a {
  color: var(--text);
}

.article-item h3 a:hover,
.timeline-item h3 a:hover,
.project-item h3 a:hover {
  color: var(--accent);
  text-decoration: none;
}

.excerpt,
.project-item p.desc,
.timeline-item p {
  font-size: 0.93rem;
}

.excerpt {
  margin: 0.5rem 0;
}

.project-item p.desc {
  margin: 0.4rem 0 0.5rem;
}

/* Tags */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.tag {
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.74rem;
}

/* Activity timeline */
.timeline {
  margin-left: 0.3rem;
  border-left: 1px solid var(--border);
}

.timeline-item {
  position: relative;
  padding: 0 0 1.5rem 1.25rem;
  margin-bottom: 24px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 0.9rem;
  left: -3.5px;
  width: 8px;
  height: 8px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--accent);
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item p {
  margin: 0.3rem 0 0;
}

/* Project links */
.links {
  display: flex;
  gap: 1.5rem;
  margin-top: 1rem;
  font-size: 1rem;
}

/* Detail views */
.back-link {
  display: inline-block;
  margin-bottom: 1.2rem;
  font-size: 0.88rem;
}

.detail-title {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}

.detail-content {
  margin-top: 1.2rem;
  font-size: 0.97rem;
}

.detail-content p {
  margin: 0 0 1rem;
}

/* Share controls */
.share-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.8rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}

.share-label {
  margin-right: 0.2rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.share-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.share-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Toast */
.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 1.5rem;
  max-width: 90vw;
  padding: 0.55rem 1rem;
  transform: translateX(-50%) translateY(10px);
  border-radius: 4px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.85rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Footer */
footer {
  padding: 1.4rem 0 calc(1.4rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
}

/* Small screens */
@media (max-width: 480px) {
  nav {
    gap: 0.8rem;
  }

  .home-hero h1 {
    font-size: 1.4rem;
  }
}
