:root {
  color-scheme: light dark;

  --bg: #faf9f6;
  --surface: #ffffff;
  --text: #1c1b18;
  --text-muted: #65625a;
  --border: #e5e2da;
  --accent: #2c5f4b;
  --accent-hover: #1f4536;
  --code-bg: #f1efe9;
  --tag-bg: #efede6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151513;
    --surface: #1c1c19;
    --text: #eae8e1;
    --text-muted: #9e9a90;
    --border: #2c2b26;
    --accent: #7ec4a5;
    --accent-hover: #a1d7bf;
    --code-bg: #22221e;
    --tag-bg: #252520;
  }
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  line-height: 1.8;
  letter-spacing: 0.015em;
  font-feature-settings: "palt" 1;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.15s ease;
}

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

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* Header & Navigation */
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.5rem;
  margin-bottom: 3rem;
  border-bottom: 1px solid var(--border);
}

.site-brand {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}

.site-brand:hover {
  color: var(--accent);
}

.site-nav {
  display: flex;
  gap: 1.25rem;
  font-size: 0.95rem;
}

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

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

/* Typography & Sections */
h1,
h2,
h3,
h4 {
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-top: 2.25rem;
  margin-bottom: 0.85rem;
}

h1 {
  font-size: 1.75rem;
  margin-top: 0;
}

h2 {
  font-size: 1.3rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 1.1rem;
}

p {
  margin-top: 0;
  margin-bottom: 1.35rem;
}

ul,
ol {
  margin-top: 0;
  margin-bottom: 1.35rem;
  padding-left: 1.4rem;
}

li + li {
  margin-top: 0.35rem;
}

blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1.1rem;
  border-left: 3px solid var(--border);
  color: var(--text-muted);
}

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

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88em;
  background-color: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

pre {
  margin: 1.5rem 0;
  padding: 1rem 1.15rem;
  background-color: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.6;
}

pre code {
  background-color: transparent;
  padding: 0;
  font-size: 0.86rem;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
  border-radius: 6px;
  transition: opacity 0.15s ease;
}

a:has(> img):hover img {
  opacity: 0.9;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.94rem;
}

th,
td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
}

/* Profile Hero */
.profile-header {
  margin-bottom: 2rem;
}

.profile-title {
  margin-bottom: 0.35rem;
}

.profile-tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
}

.recent-posts {
  margin-top: 3.5rem;
}

.section-more {
  margin-top: 1.25rem;
  font-size: 0.95rem;
}

/* Article Tree */
.article-tree {
  margin-top: 3rem;
}

.tree-year {
  margin-top: 0.75rem;
}

.tree-year summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.96rem;
  color: var(--text);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

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

.tree-year summary::before {
  content: "▸";
  font-size: 0.8em;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.tree-year[open] summary::before {
  transform: rotate(90deg);
}

.tree-count {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tree-list {
  list-style: none;
  margin: 0.4rem 0 0.75rem 0.4rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.tree-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.65rem;
  padding: 0.25rem 0;
  font-size: 0.94rem;
}

.tree-date {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.tree-link {
  color: var(--text);
  text-decoration: none;
}

.tree-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Post List */
.post-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
}

.post-item {
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--border);
}

.post-item:first-child {
  padding-top: 0.25rem;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.post-date {
  font-variant-numeric: tabular-nums;
}

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

.post-item-title:hover {
  color: var(--accent);
  text-decoration: underline;
}

.post-item-desc {
  margin: 0;
  font-size: 0.94rem;
  color: var(--text-muted);
}

/* Tags */
.tag-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  display: inline-block;
  font-size: 0.78rem;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  background-color: var(--tag-bg);
  color: var(--text-muted);
}

/* Article Page */
.article-header {
  margin-bottom: 2.25rem;
}

.article-title {
  margin-top: 0.4rem;
  margin-bottom: 0.6rem;
}

.article-description {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.98rem;
}

.article-footer {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}

/* Footer */
.site-footer {
  margin-top: 4.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .container {
    padding: 1.75rem 1.15rem 3rem;
  }

  .site-header {
    margin-bottom: 2.25rem;
  }

  h1 {
    font-size: 1.5rem;
  }
}
