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

/* Base */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  scroll-padding-top: calc(var(--site-header-height, 8rem) + 1rem);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif, "Segoe UI Emoji";
  background: #fff;
  color: rgb(0 0 0 / 82%);
  line-height: 1.8;
}

/* Page wrapper — sticky footer */
.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.page-wrapper--wide {
  max-width: 1100px;
}

.page-wrapper > main {
  flex: 1;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fff;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 2.75rem;
}

.site-title {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  max-width: 100%;
  font-size: 1rem;
  font-weight: 700;
  color: #111;
  text-decoration: none;
  letter-spacing: 0.01em;
  line-height: 1.4;
  min-height: 44px;
}

.site-title img {
  display: block;
  flex-shrink: 0;
  max-width: 100%;
  width: 140px;
  height: auto;
}

.site-title span {
  font-size: 0.875rem;
  white-space: nowrap;
}

.company-link,
.article-language a,
.post-navigation a {
  color: #111;
  text-underline-offset: 0.2em;
}

.company-link,
.article-language a {
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.post-navigation {
  margin-top: 3rem;
}

a:focus-visible {
  outline: 2px solid #111;
  outline-offset: 4px;
}

/* Post */
.post-header {
  margin-bottom: 2.75rem;
}

.post-header h1 {
  overflow-wrap: anywhere;
  margin-bottom: 1rem;
  font-size: clamp(2.2rem, 1.7rem + 2vw, 3rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: #111;
}

.post-header time {
  display: block;
  font-size: 0.95rem;
  color: #6b7280;
  line-height: 1.6;
}

.post-authors {
  font-size: 0.95rem;
  color: #6b7280;
  margin-top: 0.25rem;
  line-height: 1.6;
}

.article-language {
  margin-top: 0.75rem;
}

.post-content {
  overflow-wrap: anywhere;
  font-size: 1rem;
  line-height: 1.95;
}

.post-content p {
  margin-bottom: 2rem;
}

.post-content h2 {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.4;
  margin-top: 4rem;
  margin-bottom: 1.25rem;
  color: #111;
}

.post-content h3 {
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1.5;
  margin-top: 2.75rem;
  margin-bottom: 1rem;
  color: #111;
}

.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2.25rem 0;
}

.post-content figure {
  margin: 2.25rem 0;
}

.post-content figure img {
  margin: 0 auto;
}

.post-content figcaption {
  margin-top: 0.75rem;
  color: #666;
  font-size: 0.875rem;
  line-height: 1.6;
  text-align: center;
}

.post-content figcaption p {
  margin: 0;
}

.post-content .video-player video {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  border-radius: 8px;
}

.post-content details {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
}

.post-content summary {
  cursor: pointer;
  font-weight: 600;
}

.post-content details[open] summary {
  margin-bottom: 0.75rem;
}

.post-content details p:last-child {
  margin-bottom: 0;
}

.post-content mjx-container[display="true"] {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5rem 0;
}

.post-content a {
  color: #111;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.post-content ul,
.post-content ol {
  margin-bottom: 2rem;
  padding-left: 1.5rem;
}

.post-content li {
  margin-bottom: 0.5rem;
}

.post-content blockquote {
  border-left: 3px solid #e5e7eb;
  padding-left: 1.2rem;
  color: #666;
  margin: 2rem 0;
}

.post-content code {
  font-family: "SF Mono", "Monaco", "Inconsolata", "Fira Mono", monospace;
  font-size: 0.9em;
  background: #f5f5f5;
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.post-content pre {
  background: #f5f5f5;
  padding: 1.2rem;
  overflow-x: auto;
  margin: 2rem 0;
  border-radius: 6px;
}

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

/* References keep their anchors, with denser spacing than article paragraphs. */
.post-content h2:has(+ .footnotes) {
  font-size: 1.1rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.post-content .footnotes {
  color: #4b5563;
  font-size: 0.875rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.post-content .footnotes hr {
  border: 0;
  border-top: 1px solid #e5e7eb;
  margin-bottom: 1rem;
}

.post-content .footnotes ol {
  margin: 0;
  padding-left: 1.5rem;
}

.post-content .footnotes li {
  margin-bottom: 0.65rem;
  padding-left: 0.2rem;
  scroll-margin-top: 1.5rem;
}

.post-content .footnotes li:last-child,
.post-content .footnotes p:last-child {
  margin-bottom: 0;
}

.post-content .footnotes p {
  margin-bottom: 0.4rem;
}

.post-content .footnotes li::marker {
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

.post-content .footnote-backref {
  display: inline-block;
  padding: 0 0.15rem;
  text-decoration: none;
}

/* Article sharing */
.article-share {
  margin-top: 1.25rem;
}

.article-share-row,
.article-share-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.article-share-row {
  gap: 0.75rem 1.25rem;
  justify-content: flex-start;
}

.article-share h2 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #4b5563;
}

.share-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.4rem;
  background: #fff;
  color: #374151;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
}

.share-button[hidden] { display: none; }
.share-button:hover { background: #f3f4f6; border-color: #9ca3af; }
.share-button:focus-visible, .share-url:focus-visible { outline: 2px solid #111; outline-offset: 3px; }
.share-button svg { width: 1rem; height: 1rem; flex-shrink: 0; }

.share-status,
.share-manual {
  font-size: 0.875rem;
  color: #4b5563;
}

.share-status:not(:empty),
.share-manual:not([hidden]) { margin-top: 0.75rem; }

.share-url {
  width: 100%;
  min-width: 0;
  margin-top: 0.35rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.4rem;
  background: #f9fafb;
  color: #374151;
  font: inherit;
  font-size: 1rem;
}

/* Table */
.post-content table {
  width: 100%;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 0.95rem;
}

.post-content th,
.post-content td {
  border: 1px solid #e5e7eb;
  padding: 0.75rem 0.9rem;
  min-width: 140px;
  text-align: left;
}

.post-content th {
  background: #fafafa;
  font-weight: 700;
  color: #111;
}

.post-content tr:hover {
  background: #fafafa;
}

/* Audio Table */
.audio-table audio {
  width: 100%;
  min-width: 200px;
  display: block;
}

/* Audio Player */
.audio-player {
  margin-bottom: 2.5rem;
  padding: 1.2rem;
  background: #fafafa;
  border-radius: 8px;
}

.audio-player audio {
  width: 100%;
  display: block;
}

/* Post with TOC layout */
.post-wrapper {
  display: flex;
  gap: 4rem;
  align-items: flex-start;
}

.post-wrapper .post {
  flex: 1;
  min-width: 0;
  max-width: 760px;
}

/* TOC */
.toc {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--site-header-height, 8rem) + 2rem);
  max-height: calc(100vh - var(--site-header-height, 8rem) - 4rem);
  overflow-y: auto;
}

.toc-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.8rem;
}

.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc li {
  margin-bottom: 0.45rem;
}

.toc li.toc-h3 {
  padding-left: 1rem;
}

.toc a {
  font-size: 0.85rem;
  color: #9ca3af;
  text-decoration: none;
  line-height: 1.6;
  display: block;
  transition: color 0.15s;
}

.toc a:hover {
  color: #374151;
}

.toc a.active {
  color: #111;
  font-weight: 600;
}

/* Footer */
footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  padding-bottom: 3rem;
  border-top: 1px solid #e5e7eb;
  font-size: 0.85rem;
  color: #9ca3af;
}

/* Post listing */
.post-list-wrapper {
  max-width: 760px;
}

.post-list-title {
  font-size: clamp(2.2rem, 1.7rem + 2vw, 3rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: #111;
  margin-bottom: 2.75rem;
  overflow-wrap: anywhere;
}

.post-list-title:has(+ .post-list-description) {
  margin-bottom: 1rem;
}

.post-list-description {
  margin-bottom: 2rem;
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list li {
  border-bottom: 1px solid #e5e7eb;
}

.post-list-link {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.25rem 0;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.post-list-link:hover {
  background: #fafafa;
}

.post-list-item-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #111;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.post-list-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 1rem;
}

.post-list-language {
  font-size: 0.85rem;
  color: #4b5563;
}

.post-list-link time {
  font-size: 0.9rem;
  color: #6b7280;
}

.post-list-authors {
  font-size: 0.9rem;
  color: #6b7280;
}

.post-list-empty {
  padding: 1.25rem 0;
}

/* Responsive */
@media (min-width: 901px) {
  /* A fixed bar can change height without moving the article underneath. */
  .page-wrapper {
    padding-top: calc(85px + 2.75rem);
  }

  .site-header {
    position: fixed;
    inset: 0 0 auto;
    margin-bottom: 0;
    padding-inline: max(1.5rem, calc((100% - 1100px) / 2 + 1.5rem));
  }

  .site-header[data-header-compact] {
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
  }

  .toc {
    top: calc(85px + 2rem);
    max-height: calc(100vh - 85px - 4rem);
  }
}

@media (min-width: 901px) and (prefers-reduced-motion: no-preference) {
  .site-header {
    transition: padding-top 200ms ease, padding-bottom 200ms ease;
  }
}

@media (max-width: 900px) {
  .page-wrapper--wide {
    max-width: 760px;
  }

  .post-wrapper {
    flex-direction: column-reverse;
    gap: 0;
  }

  .post-wrapper .post {
    max-width: 100%;
  }

  .toc {
    display: none;
  }

  .toc-title {
    display: none;
  }
}

@media (max-width: 600px) {
  .page-wrapper {
    padding: 0 1rem;
  }

  .site-header {
    padding-top: 1rem;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
  }

  .post-header {
    margin-bottom: 2rem;
  }

  .post-header h1 {
    font-size: clamp(1.8rem, 1.45rem + 2vw, 2.2rem);
    line-height: 1.3;
    margin-bottom: 0.8rem;
  }

  .post-header time,
  .post-authors {
    font-size: 0.9rem;
  }

  .post-content h2 {
    font-size: 1.4rem;
    margin-top: 3rem;
    margin-bottom: 1rem;
  }

  .post-content h3 {
    font-size: 1.15rem;
    margin-top: 2.2rem;
    margin-bottom: 0.8rem;
  }

  .post-content p,
  .post-content ul,
  .post-content ol,
  .post-content blockquote,
  .post-content pre,
  .post-content table {
    margin-bottom: 1.6rem;
  }

  .post-list li {
    flex-direction: column;
    gap: 0.2rem;
  }
}
