:root {
  --bg:        #0d0d0d;
  --fg:        #e8e8e8;
  --accent:    #00ffaa;
  --muted:     #555555;
  --surface:   #161616;
  --border:    #2a2a2a;
  --font:      'JetBrains Mono', 'Fira Mono', monospace;
  --font-size: 15px;
  --line:      1.7;
  --max-width: 720px;
  --header-h:  85px;
}

[data-theme="light"] {
  --bg:      #f5f5f0;
  --fg:      #1a1a1a;
  --accent:  #007a4a;
  --muted:   #888888;
  --surface: #ebebeb;
  --border:  #d5d5d5;
}

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

html {
  font-size: var(--font-size);
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  line-height: var(--line);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */

header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 100;
}

.site-name {
  color: var(--accent);
  font-size: 2.5rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.04em;
}

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

.ctrl-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.3rem 0.7rem;
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  line-height: 1.5;
}

.ctrl-btn:hover {
  color: var(--fg);
  border-color: var(--muted);
}

header nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 1rem;
  transition: color 0.15s;
}

header nav a:hover,
header nav a[aria-current="page"] {
  color: var(--fg);
}

/* ── Main ── */

main {
  flex: 1;
  margin-top: var(--header-h);
  padding: 2.5rem 1.5rem;
  width: 100%;
  max-width: calc(var(--max-width) + 3rem);
  margin-left: auto;
  margin-right: auto;
}

/* ── Typography ── */

h1, h2, h3, h4 {
  line-height: 1.3;
  margin-bottom: 0.5em;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

p { margin-bottom: 1em; }

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

a:hover {
  text-decoration: underline;
}

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

/* ── Code ── */

code {
  background: var(--surface);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: var(--font);
}

.code-block {
  position: relative;
  margin: 1.5rem 0;
}

.code-block pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem 1rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
  tab-size: 2;
}

.code-block pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--border);
  color: var(--muted);
  border: none;
  border-radius: 3px;
  padding: 0.2rem 0.5rem;
  font-family: var(--font);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1.5;
}

.copy-btn:hover {
  background: var(--muted);
  color: var(--fg);
}

.copy-btn.copied {
  color: var(--accent);
  background: var(--border);
}

/* ── Portal links ── */

.portal-links {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 2rem;
}

.portal-links a {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  text-decoration: none;
  transition: border-color 0.15s;
}

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

.portal-links .link-label {
  color: var(--accent);
  min-width: 8ch;
}

.portal-links .link-desc {
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── Footer ── */

footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Project grid ── */

.project-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.project-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  color: var(--fg);
  text-decoration: none;
  transition: border-color 0.15s;
}

.project-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.project-card img {
  width: 100%;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
  display: block;
  background: var(--surface);
}

.project-card-body {
  padding: 0.35rem 0.5rem;
}

.project-card-name {
  color: var(--accent);
  font-size: 0.75rem;
  margin-bottom: 0.1rem;
}

.project-card-desc {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4;
}

/* ── Heading prefix ── */

.h-prefix {
  color: var(--muted);
  user-select: none;
}

/* ── Post updated ── */

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

/* ── Shiki syntax highlighting ── */

.code-block .shiki {
  display: block;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
  tab-size: 2;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem 1rem;
  margin: 0;
}

html[data-theme="dark"] .shiki,
html[data-theme="dark"] .shiki span {
  color: var(--shiki-dark) !important;
  background-color: var(--shiki-dark-bg) !important;
  font-style: var(--shiki-dark-font-style) !important;
  font-weight: var(--shiki-dark-font-weight) !important;
  text-decoration: var(--shiki-dark-text-decoration) !important;
}

html[data-theme="light"] .shiki,
html[data-theme="light"] .shiki span {
  color: var(--shiki-light) !important;
  background-color: var(--shiki-light-bg) !important;
  font-style: var(--shiki-light-font-style) !important;
  font-weight: var(--shiki-light-font-weight) !important;
  text-decoration: var(--shiki-light-text-decoration) !important;
}

/* ── Post list (blog / gist index) ── */

.post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 1.5rem;
}

.post-list a {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.5rem 0;
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: color 0.15s;
}

.post-list a:hover {
  color: var(--accent);
  text-decoration: none;
}

.post-list-date {
  color: var(--muted);
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* ── Nav separator ── */

.nav-sep {
  width: 1px;
  height: 1rem;
  background: var(--border);
  flex-shrink: 0;
}

/* ── Language switching ── */

[data-lang="en"] .ja { display: none; }
[data-lang="ja"] .en { display: none; }

/* ── Post meta ── */

.post-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag {
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  font-size: 0.8rem;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

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

/* ── Prev / Next navigation ── */

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.post-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  text-decoration: none;
  transition: border-color 0.15s;
}

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

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

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

.post-nav-title {
  font-size: 0.875rem;
}
