/* ============================================================
   Hatena Blog Theme — "Codex"
   Light editorial × hacker aesthetic
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Shippori+Mincho:wght@400;500;700&family=Space+Mono:ital,wght@0,400;0,700;1,400&family=Zen+Kaku+Gothic+New:wght@300;400;700&display=swap');

/* ── Design Tokens ──────────────────────────────────────── */
:root {
  --bg:          #f5f2eb;
  --bg-alt:      #ede9df;
  --surface:     #ffffff;
  --border:      #d8d3c8;
  --border-light:#ece8e0;
  --text:        #1c1a16;
  --text-sub:    #4a4640;
  --text-muted:  #8a857a;
  --accent:      #9b7a2a;
  --accent-dim:  #c8a96e;
  --accent-bg:   rgba(155, 122, 42, 0.07);
  --mono:        'Space Mono', monospace;
  --serif:       'Shippori Mincho', 'Hiragino Mincho ProN', serif;
  --sans:        'Zen Kaku Gothic New', 'Hiragino Sans', sans-serif;
}

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 2;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
}

/* ── Hatena Global Header (top bar) ─────────────────────── */
.globalheader-container,
#globalheader-container {
  background: var(--text) !important;
  border-bottom: 2px solid var(--accent) !important;
}

.globalheader-inner {
  color: var(--bg) !important;
}

/* ── Page Wrapper ───────────────────────────────────────── */
#container,
#container-inner {
  max-width: 100%;
  background: var(--bg);
}

#content {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px;
}

#content-inner {
  display: flex;
  gap: 48px;
  align-items: flex-start;
}

/* ── Blog Header ────────────────────────────────────────── */
#blog-title-inner,
.page-header {
  padding: 56px 24px 40px;
  max-width: 900px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}

#blog-title h1,
.page-header h1 {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: 0.06em;
  color: var(--text);
  margin: 0 0 8px;
}

#blog-title a,
.page-header h1 a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s;
}

#blog-title a:hover,
.page-header h1 a:hover {
  color: var(--accent);
}

#blog-description,
.blog-description {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  margin: 0;
}

/* ── Main Column ────────────────────────────────────────── */
.main,
#main {
  flex: 1;
  min-width: 0;
}

/* ── Entry / Post ───────────────────────────────────────── */
.entry {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 2px;
  padding: 40px 48px 36px;
  margin-bottom: 40px;
  position: relative;
  transition: box-shadow 0.25s;
}

.entry:hover {
  box-shadow: 0 4px 24px rgba(28, 26, 22, 0.07);
}

/* 左ライン装飾 */
.entry::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--accent), transparent);
  border-radius: 2px 0 0 2px;
}

/* ── Entry Header ───────────────────────────────────────── */
.entry-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

/* 日付 */
.date,
.entry-date {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: block;
}

.date a,
.entry-date a {
  color: var(--text-muted);
  text-decoration: none;
}

/* タイトル */
.entry-title {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.55;
  letter-spacing: 0.03em;
  margin: 0 0 14px;
  color: var(--text);
}

.entry-title a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s;
}

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

/* カテゴリ */
.categories,
.entry-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.categories a,
.entry-categories a,
.category-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid rgba(155, 122, 42, 0.2);
  padding: 2px 8px;
  border-radius: 2px;
  text-decoration: none;
  text-transform: uppercase;
  transition: background 0.2s;
}

.categories a:hover,
.entry-categories a:hover {
  background: rgba(155, 122, 42, 0.14);
}

/* ── Entry Content (本文) ────────────────────────────────── */
.entry-content {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 2.05;
  color: var(--text);
}

.entry-content p {
  margin: 0 0 1.6em;
  color: var(--text);
}

/* 見出し */
.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4 {
  font-family: var(--sans);
  font-weight: 700;
  color: var(--text);
  margin: 2em 0 0.8em;
  line-height: 1.5;
  letter-spacing: 0.04em;
}

.entry-content h2 {
  font-size: 17px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.entry-content h2::before {
  content: '//';
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent-dim);
  margin-right: 8px;
}

.entry-content h3 {
  font-size: 15px;
  color: var(--accent);
}

/* リンク */
.entry-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(155, 122, 42, 0.35);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}

.entry-content a:hover {
  text-decoration-color: var(--accent);
}

/* 引用 */
.entry-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 16px 20px;
  margin: 28px 0;
  background: var(--accent-bg);
  border-radius: 0 4px 4px 0;
  color: var(--text-sub);
  font-style: italic;
}

.entry-content blockquote p { margin-bottom: 0; }

/* コード */
.entry-content code {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid rgba(155, 122, 42, 0.18);
  padding: 1px 5px;
  border-radius: 3px;
}

.entry-content pre {
  background: var(--text);
  color: #d4d0c8;
  padding: 20px 24px;
  border-radius: 4px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  margin: 24px 0;
}

.entry-content pre code {
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

/* 画像 */
.entry-content img {
  max-width: 100%;
  height: auto;
  border-radius: 2px;
  display: block;
  margin: 24px auto;
}

/* リスト */
.entry-content ul,
.entry-content ol {
  padding-left: 1.5em;
  margin: 0 0 1.4em;
  color: var(--text);
}

.entry-content li { margin-bottom: 0.4em; }

/* 水平線 */
.entry-content hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 40px 0;
}

/* 太字・強調 */
.entry-content strong { color: var(--text); font-weight: 700; }
.entry-content em { color: var(--text-sub); }

/* ── Entry Footer ───────────────────────────────────────── */
.entry-footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.entry-footer-section {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

/* いいねボタン・コメント数など */
.social-buttons,
.entry-footer .hatena-star,
.entry-footer .comment-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Pagination ─────────────────────────────────────────── */
.pager,
.page-navi {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0 40px;
  font-family: var(--mono);
  font-size: 12px;
}

.pager a,
.page-navi a {
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.1em;
  padding: 6px 14px;
  border: 1px solid rgba(155, 122, 42, 0.3);
  border-radius: 2px;
  transition: all 0.2s;
}

.pager a:hover,
.page-navi a:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
}

/* ── Sidebar ────────────────────────────────────────────── */
#box2,
.hatena-module-body {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 24px;
}

.hatena-module {
  margin-bottom: 32px;
}

.hatena-module-title,
.hatena-module-title a {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  display: block;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.hatena-module ul,
.hatena-module ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.hatena-module li {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text-sub);
  padding: 5px 0;
  border-bottom: 1px solid var(--border-light);
}

.hatena-module li a {
  color: var(--text-sub);
  text-decoration: none;
  transition: color 0.2s;
}

.hatena-module li a:hover {
  color: var(--accent);
}

/* 検索ボックス */
.hatena-module-search-box input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.hatena-module-search-box input[type="text"]:focus {
  border-color: var(--accent);
}

/* ── Footer ─────────────────────────────────────────────── */
#footer {
  background: var(--text);
  color: var(--bg);
  border-top: 2px solid var(--accent);
  text-align: center;
  padding: 32px 24px;
  margin-top: 60px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: #8a857a;
}

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

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 720px) {
  #content { padding: 0 16px; }

  #content-inner {
    flex-direction: column;
    gap: 0;
  }

  #box2,
  .hatena-module-body {
    width: 100%;
    position: static;
  }

  .entry {
    padding: 28px 24px 24px;
  }

  #blog-title-inner,
  .page-header {
    padding: 36px 16px 28px;
  }
}

    :root {
      --bg: #0b0b0f;
      --surface: #111118;
      --border: #1e1e2e;
      --text: #d4d0c8;
      --text-muted: #6b6880;
      --accent: #c8a96e;
      --accent-dim: #7a6440;
      --highlight: #e8e4d8;
      --mono: 'Space Mono', monospace;
      --serif: 'Shippori Mincho', serif;
      --sans: 'Zen Kaku Gothic New', sans-serif;
    }

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

    body {
      background: var(--bg);
      color: var(--text);
      font-family: var(--serif);
      font-size: 17px;
      line-height: 2;
      -webkit-font-smoothing: antialiased;
    }

    /* ── noise overlay ── */
    body::before {
      content: '';
      position: fixed;
      inset: 0;
      background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
      pointer-events: none;
      z-index: 9999;
      opacity: 0.4;
    }

    .article-wrap {
      max-width: 740px;
      margin: 0 auto;
      padding: 80px 32px 120px;
    }

    /* ── header ── */
    .article-header {
      margin-bottom: 64px;
      animation: fadeUp 0.8s ease both;
    }

    .tag-line {
      font-family: var(--mono);
      font-size: 11px;
      letter-spacing: 0.2em;
      color: var(--accent);
      text-transform: uppercase;
      margin-bottom: 24px;
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .tag-line::before {
      content: '';
      display: inline-block;
      width: 24px;
      height: 1px;
      background: var(--accent);
    }

    h1 {
      font-family: var(--serif);
      font-size: clamp(26px, 5vw, 38px);
      font-weight: 700;
      color: var(--highlight);
      line-height: 1.5;
      letter-spacing: 0.02em;
      margin-bottom: 24px;
    }

    .subtitle-bar {
      display: flex;
      align-items: center;
      gap: 16px;
      padding-top: 20px;
      border-top: 1px solid var(--border);
    }

    .subtitle-bar time {
      font-family: var(--mono);
      font-size: 12px;
      color: var(--text-muted);
    }

    /* ── divider ── */
    .sep {
      width: 48px;
      height: 1px;
      background: linear-gradient(to right, var(--accent), transparent);
      margin: 48px 0;
    }

    /* ── body text ── */
    .article-body p {
      margin-bottom: 1.8em;
      color: var(--text);
      animation: fadeUp 0.6s ease both;
    }

    /* ── section headings ── */
    .article-body h2 {
      font-family: var(--sans);
      font-size: 13px;
      font-weight: 700;
      letter-spacing: 0.18em;
      color: var(--accent);
      text-transform: uppercase;
      margin: 56px 0 20px;
      display: flex;
      align-items: center;
      gap: 12px;
      animation: fadeUp 0.6s ease both;
    }

    .article-body h2::before {
      content: '//';
      font-family: var(--mono);
      color: var(--accent-dim);
    }

    /* ── pull quote / callout ── */
    .callout {
      border-left: 2px solid var(--accent);
      padding: 20px 24px;
      margin: 40px 0;
      background: rgba(200, 169, 110, 0.04);
      border-radius: 0 4px 4px 0;
      animation: fadeUp 0.6s ease both;
    }

    .callout p {
      font-size: 18px;
      color: var(--highlight);
      font-style: italic;
      margin-bottom: 0 !important;
      line-height: 1.9;
    }

    /* ── inline code / term ── */
    .term {
      font-family: var(--mono);
      font-size: 0.88em;
      color: var(--accent);
      background: rgba(200, 169, 110, 0.08);
      padding: 1px 6px;
      border-radius: 3px;
      border: 1px solid rgba(200, 169, 110, 0.15);
    }

    /* ── closing flourish ── */
    .article-footer {
      margin-top: 80px;
      padding-top: 32px;
      border-top: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      animation: fadeUp 0.6s ease both;
    }

    .closing-phrase {
      font-family: var(--sans);
      font-weight: 700;
      font-size: 20px;
      color: var(--highlight);
      letter-spacing: 0.06em;
    }

    .closing-mono {
      font-family: var(--mono);
      font-size: 11px;
      color: var(--text-muted);
      letter-spacing: 0.15em;
    }

    /* ── decorative corner mark ── */
    .corner-mark {
      position: fixed;
      top: 28px;
      right: 32px;
      font-family: var(--mono);
      font-size: 11px;
      color: var(--border);
      letter-spacing: 0.1em;
      pointer-events: none;
    }

    @keyframes fadeUp {
      from { opacity: 0; transform: translateY(16px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    .article-body p:nth-child(1) { animation-delay: 0.05s; }
    .article-body p:nth-child(2) { animation-delay: 0.10s; }
    .article-body p:nth-child(3) { animation-delay: 0.15s; }
    .article-body p:nth-child(4) { animation-delay: 0.20s; }
    .article-body p:nth-child(5) { animation-delay: 0.25s; }

    @media (max-width: 600px) {
      .article-wrap { padding: 48px 20px 80px; }
      .article-footer { flex-direction: column; align-items: flex-start; gap: 8px; }
    }