:root{
  --bg: #EAF7FC;
  --bg-alt: #D8EFF7;
  --surface: #FFFFFF;
  --ink: #123247;
  --ink-soft: #4C7489;
  --blue-500: #1CA7DE;
  --blue-600: #1590C4;
  --blue-700: #0B6E96;
  --amber-400: #FFAE42;
  --line: #BFE2EF;
  --radius: 10px;
  --header-h: 64px;
  --footer-h: 60px;
  --side-w: 232px;
  --right-w: 296px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

*{ box-sizing: border-box; }
html{ scroll-behavior: smooth; }
body{
  margin:0;
  background:
    linear-gradient(var(--bg-line-fade,transparent),transparent),
    repeating-linear-gradient(0deg, rgba(28,167,222,0.055) 0 1px, transparent 1px 34px),
    repeating-linear-gradient(90deg, rgba(28,167,222,0.055) 0 1px, transparent 1px 34px),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a{ color: inherit; text-decoration: none; }
ul{ list-style: none; margin:0; padding:0; }
h1,h2,h3{ font-family: var(--font-display); margin:0 0 .5em; color: var(--ink); }
button{ font-family: inherit; cursor:pointer; }
:focus-visible{ outline: 3px solid var(--amber-400); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior:auto !important; }
}

/* ---------- Browser-chrome mark (signature) ---------- */
.chrome-mark{
  display:inline-flex; align-items:center; gap:6px;
  width:40px; height:40px; border-radius: 9px;
  background: linear-gradient(155deg, var(--blue-500), var(--blue-700));
  padding: 0 0 0 9px;
  flex-shrink:0;
}
.chrome-mark span{
  width:6px; height:6px; border-radius:50%;
  background: rgba(255,255,255,0.9);
}
.chrome-mark span:nth-child(2){ background: rgba(255,255,255,0.65);}
.chrome-mark span:nth-child(3){ background: rgba(255,255,255,0.4);}

.window-chrome{
  display:flex; align-items:center; gap:5px;
  padding: 8px 10px; background: var(--bg-alt);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
}
.window-chrome i{ width:8px; height:8px; border-radius:50%; background: #9FD3E8; display:block; }
.window-chrome i:nth-child(1){ background:#FF9F7A; }
.window-chrome i:nth-child(2){ background:#FFD37A; }
.window-chrome i:nth-child(3){ background:#7ADF9E; }
.window-chrome .url{
  margin-left:8px; font-family: var(--font-mono); font-size:11px;
  color: var(--ink-soft); background: var(--surface);
  border-radius: 5px; padding: 2px 8px; flex:1; overflow:hidden;
  text-overflow: ellipsis; white-space:nowrap;
}

/* ---------- Header ---------- */
.site-header{
  position: sticky; top:0; z-index: 40;
  height: var(--header-h);
  display:flex; align-items:center;
  background: rgba(234,247,252,0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner{
  width:100%; max-width:1440px; margin:0 auto;
  display:flex; align-items:center; gap:14px;
  padding: 0 16px;
}
.hamburger{
  display:flex; flex-direction:column; justify-content:center; gap:4px;
  width:38px; height:38px; border:1px solid var(--line);
  border-radius:8px; background: var(--surface);
}
.hamburger span{ height:2px; width:18px; background: var(--blue-700); margin:0 auto; border-radius:2px; }
.logo{ display:flex; align-items:center; gap:10px; }
.logo strong{ font-family: var(--font-display); font-size:17px; letter-spacing:.2px; }
.logo small{ display:block; font-size:11px; color: var(--ink-soft); font-family: var(--font-mono); }
.cursor-blink{
  display:inline-block; width:7px; height:1em; background: var(--blue-500);
  margin-left:2px; vertical-align:-2px; animation: blink 1.1s steps(1) infinite;
}
@keyframes blink{ 50%{ opacity:0; } }

.header-nav-pc{ margin-left:auto; display:none; align-items:center; gap:20px; }
.header-nav-pc a{ font-size:14px; color: var(--ink-soft); font-weight:500; }
.header-nav-pc a:hover{ color: var(--blue-700); }
.site-search{
  position:relative;
  display:flex; align-items:center; gap:6px;
  border:1px solid var(--line); background:var(--surface);
  border-radius:20px; padding:6px 12px; font-size:13px; color:var(--ink-soft);
}
.site-search-input{
  border:none; background:none; outline:none;
  font-family: var(--font-body); font-size:13px; color: var(--ink);
  width:150px;
}
.site-search-input::-webkit-search-cancel-button{ cursor:pointer; }
.search-results{
  position:absolute; top:calc(100% + 8px); right:0; width:280px;
  background: var(--surface); border:1px solid var(--line); border-radius:10px;
  box-shadow: 0 10px 24px rgba(11,110,150,0.16);
  padding:6px; max-height:320px; overflow-y:auto; z-index:50;
}
.search-results a{
  display:block; padding:8px 10px; border-radius:7px; font-size:13px; color: var(--ink);
}
.search-results a:hover, .search-results a:focus-visible{ background: var(--bg-alt); }
.search-results .result-tag{
  font-family: var(--font-mono); font-size:10.5px; color: var(--blue-700); display:block; margin-bottom:2px;
}
.search-empty{ padding:10px 8px; font-size:12.5px; color: var(--ink-soft); }

/* ---------- Layout grid ---------- */
.layout{
  max-width:1440px; margin:0 auto;
  display:block;
  padding: 0 16px;
}

.side-menu{
  position: fixed; top:0; left:0; height:100%; width: 78%; max-width:300px;
  background: var(--surface); z-index: 60;
  padding: 18px 18px 18px;
  transform: translateX(-105%);
  transition: transform .28s ease;
  overflow-y:auto;
  box-shadow: 2px 0 24px rgba(11,110,150,0.18);
}
.side-menu.open{ transform: translateX(0); }
.side-menu-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom: 18px; }
.side-menu-close{ width:32px; height:32px; border-radius:7px; border:1px solid var(--line); background:var(--bg-alt); font-size:16px; line-height:1; }

.menu-eyebrow{
  font-family: var(--font-mono); font-size:11px; color: var(--blue-600);
  letter-spacing: .06em; margin: 18px 0 8px; padding-left:4px;
}
.menu-list a{
  display:flex; align-items:center; gap:10px;
  padding:10px 12px; border-radius:8px; font-size:14.5px; font-weight:500;
  color: var(--ink);
}
.menu-list a:hover{ background: var(--bg-alt); color: var(--blue-700); }
.menu-list a .dot{ width:6px; height:6px; border-radius:50%; background: var(--line); flex-shrink:0; }
.menu-list a:hover .dot{ background: var(--blue-500); }
.menu-list a .external-icon{ margin-left:auto; font-size:12px; color: var(--ink-soft); flex-shrink:0; }
.menu-list a:hover .external-icon{ color: var(--blue-700); }
.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}
.menu-list .active a{ background: var(--bg-alt); color: var(--blue-700); }
.menu-list .active a .dot{ background: var(--amber-400); }

.menu-sublist{
  margin-left:10px; padding-left:12px;
  border-left:1px dashed var(--line);
}
.menu-sublist a{ font-size:13px; padding:6px 10px; color: var(--ink-soft); font-weight:500; }
.menu-sublist a .dot{ width:5px; height:5px; }
.menu-sublist a:hover{ color: var(--blue-700); }

.social-links{ display:flex; gap:8px; flex-wrap:wrap; padding-left:4px; }
.social-badge{
  display:flex; align-items:center; justify-content:center;
  min-width:44px; height:34px; padding:0 10px; border-radius:8px;
  font-family: var(--font-mono); font-size:11.5px; font-weight:600;
  color:#fff; letter-spacing:.02em;
  transition: transform .15s ease, opacity .15s ease;
}
.social-badge:hover{ transform: translateY(-2px); opacity:.88; }
.social-x{ background:#111318; }
.social-note{ background:#3DBE95; }
.social-github{ background:#24292F; }
.social-qiita{ background:#55C500; }

.menu-overlay{
  position: fixed; inset:0; background: rgba(11,45,61,0.35);
  z-index: 55; opacity:0; pointer-events:none; transition: opacity .25s ease;
}
.menu-overlay.show{ opacity:1; pointer-events:auto; }

/* ---------- Main content ---------- */
.content{ padding: 28px 0 40px; min-width:0; }

.hero{
  background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
  border-radius: 16px;
  padding: 34px 26px;
  color: #fff;
  margin-bottom: 30px;
  position: relative;
  overflow: hidden;
}
.hero::after{
  content:"";
  position:absolute; inset:0;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.07) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.07) 0 1px, transparent 1px 28px);
  pointer-events:none;
}
.hero-eyebrow{
  font-family: var(--font-mono); font-size:12px; letter-spacing:.08em;
  background: rgba(255,255,255,.16); display:inline-block; padding:4px 10px;
  border-radius:20px; margin-bottom: 14px;
}
.hero h1{ color:#fff; font-size: clamp(22px, 4.4vw, 32px); max-width: 26ch; position:relative; }
.hero p{ max-width: 46ch; color: rgba(255,255,255,.88); font-size:14.5px; position:relative; margin:10px 0 0; }

.section-head{ display:flex; align-items:baseline; justify-content:space-between; margin-bottom:16px; }
.section-head h2{ font-size:19px; }
.section-head .see-all{ font-size:13px; color: var(--blue-700); font-weight:600; }

.sort-bar{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin:6px 0 20px; }
.sort-bar label{ display:flex; align-items:center; gap:6px; font-size:12.5px; color: var(--ink-soft); font-weight:500; }
.sort-bar select{
  font-family: var(--font-body); font-size:13px; color: var(--ink);
  background: var(--surface); border:1px solid var(--line); border-radius:8px;
  padding:6px 10px; cursor:pointer;
}
.sort-bar select:hover{ border-color: var(--blue-500); }

.article-grid{ display:grid; grid-template-columns: 1fr; gap:16px; margin-bottom: 36px; }
.article-empty{
  grid-column: 1 / -1;
  background: var(--surface); border:1px dashed var(--line); border-radius: var(--radius);
  padding: 28px 16px; text-align:center; color: var(--ink-soft); font-size:13.5px;
}

.card{
  background: var(--surface); border:1px solid var(--line);
  border-radius: var(--radius); overflow:hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover{ transform: translateY(-3px); box-shadow: 0 10px 24px rgba(11,110,150,0.14); }
.card-body{ padding: 16px 16px 18px; }
.card-tags{ display:flex; gap:6px; flex-wrap:wrap; margin-bottom:10px; }
.tag{
  font-family: var(--font-mono); font-size:11px; color: var(--blue-700);
  background: var(--bg-alt); padding:3px 8px; border-radius:5px;
}
.card h3{ font-size:16.5px; margin-bottom:6px; }
.card p{ font-size:13.5px; color: var(--ink-soft); margin:0 0 12px; }
.card-meta{ display:flex; justify-content:space-between; align-items:center; font-size:12px; color: var(--ink-soft); }
.read-more{ color: var(--blue-700); font-weight:600; font-size:12.5px; }
.read-more:hover{ text-decoration: underline; }

.tool-card .window-chrome + .card-body{ padding-top:14px; }

.pagination{
  display:flex; justify-content:center; align-items:center; gap:12px;
  margin: 4px 0 36px; font-family: var(--font-mono); font-size:13px;
}
.pagination a, .pagination .page-disabled{
  display:inline-flex; align-items:center; justify-content:center;
  min-width:88px; height:36px; padding:0 12px;
  border:1px solid var(--line); border-radius:8px; background: var(--surface);
  color: var(--blue-700); font-weight:600;
}
.pagination a:hover{ background: var(--bg-alt); }
.pagination .page-disabled{ color: var(--ink-soft); opacity:.5; border-style:dashed; }
.pagination .page-info{ color: var(--ink-soft); }

/* ---------- Right pane (topics + ad) ---------- */
.side-right{ display:flex; flex-direction:column; gap:20px; margin-bottom: 30px; }
.widget{
  background: var(--surface); border:1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.widget h3{ font-size:14px; margin-bottom:12px; display:flex; align-items:center; gap:8px; }
.widget h3::before{ content:""; width:4px; height:14px; background: var(--blue-500); border-radius:2px; display:inline-block; }
.topic-cloud{ display:flex; flex-wrap:wrap; gap:8px; }
.topic-cloud a{
  font-size:12.5px; padding: 5px 10px; border-radius: 6px;
  background: var(--bg-alt); color: var(--blue-700); font-weight:500;
}
.topic-cloud a:hover{ background: var(--blue-500); color:#fff; }

.ad-widget{ border-style:dashed; text-align:center; }
.ad-widget .ad-label{
  font-family: var(--font-mono); font-size:10px; letter-spacing:.08em;
  color: var(--ink-soft); margin-bottom:10px; text-transform:uppercase;
}
.ad-slot{
  background: var(--bg-alt); border-radius:8px; height:220px;
  display:flex; align-items:center; justify-content:center;
  color: var(--ink-soft); font-size:12px; font-family: var(--font-mono);
}

/* ---------- Footer ---------- */
.site-footer{
  border-top:1px solid var(--line); background: var(--bg-alt);
  padding: 22px 16px; margin-top: 10px;
}
.footer-inner{
  max-width:1440px; margin:0 auto; display:flex; flex-direction:column; gap:6px;
  align-items:center; text-align:center;
}
.footer-inner p{ font-size:12.5px; color: var(--ink-soft); margin:0; font-family: var(--font-mono); }
.footer-links{ display:flex; gap:14px; font-size:12.5px; margin-bottom:4px; }
.footer-links a:hover{ color: var(--blue-700); }

.mobile-footer-nav{ display:none; }

/* ---------- Ad overlay (mobile: shown on random transitions) ---------- */
.ad-overlay{
  position: fixed; inset:0; background: rgba(9,38,52,0.55);
  display:flex; align-items:flex-end; justify-content:center;
  z-index: 100; opacity:0; pointer-events:none; transition: opacity .2s ease;
}
.ad-overlay.show{ opacity:1; pointer-events:auto; }
.ad-overlay-inner{
  background:#fff; width:100%; max-width:480px; border-radius: 16px 16px 0 0;
  padding: 18px 18px 22px; transform: translateY(16px); transition: transform .25s ease;
  box-shadow: 0 -8px 30px rgba(11,45,61,0.25);
}
.ad-overlay.show .ad-overlay-inner{ transform: translateY(0); }
.ad-overlay-top{ display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
.ad-overlay-top .ad-label{ font-family: var(--font-mono); font-size:10px; color: var(--ink-soft); letter-spacing:.08em; text-transform:uppercase; }
.ad-close{ width:30px; height:30px; border-radius:50%; border:1px solid var(--line); background: var(--bg-alt); font-size:14px; }
.ad-body{
  background: var(--bg-alt); border-radius:10px; height: 150px;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px;
  color: var(--ink-soft); font-size:12.5px;
}
.ad-cta{
  margin-top:14px; width:100%; background: var(--blue-500); color:#fff;
  border:none; padding:11px; border-radius:8px; font-weight:600; font-size:14px;
}

/* ---------- Article detail page ---------- */
.article-detail{
  background: var(--surface); border:1px solid var(--line); border-radius: var(--radius);
  padding: 26px 22px; margin-bottom: 30px;
}
.article-detail-meta{ display:flex; gap:10px; align-items:center; font-size:12.5px; color: var(--ink-soft); margin-bottom:14px; }
.article-detail h1{ font-size: clamp(20px, 3.6vw, 28px); }
.article-body{ font-size:15px; color: var(--ink); }
.article-body h2{ font-size:19px; margin-top:1.6em; }
.article-body h3{ font-size:16px; margin-top:1.4em; }
.article-body p{ margin: 0 0 1em; }
.article-body pre{
  background: var(--bg-alt); border-radius:8px; padding:14px; overflow-x:auto;
  font-family: var(--font-mono); font-size:13px;
}
.article-body pre.mermaid{
  background: var(--surface); border:1px solid var(--line); text-align:center;
  padding:20px; overflow-x:auto;
}
.article-body pre.mermaid svg{ max-width:100%; height:auto; }
.article-body pre.swimlane{
  background: var(--surface); border:1px solid var(--line); text-align:center;
  padding:20px; overflow-x:auto;
}
.article-body pre.swimlane svg{ max-width:100%; height:auto; }
.article-body pre.swimlane.swimlane-error{
  text-align:left; white-space:pre-wrap; font-family: var(--font-mono); font-size:13px;
  color:#9B2C43; background:#FFF1F3; border-color:#E8637A;
}
.article-body code{ font-family: var(--font-mono); font-size:.92em; background: var(--bg-alt); padding:.1em .35em; border-radius:4px; }
.article-body pre code{ background:none; padding:0; }
.article-body pre[class*="language-"]{
  /* 背景・文字色はPrismテーマ（themes/prism-tomorrow.min.css）に委ねる */
  border-radius:8px; padding:14px; margin:0 0 1em; text-shadow:none;
}
.article-body pre[class*="language-"] code[class*="language-"]{
  background:none; padding:0; text-shadow:none;
}
.article-body a{ color: var(--blue-700); text-decoration: underline; }
.article-body ul, .article-body ol{ margin:0 0 1em; padding-left: 1.4em; list-style: revert; }
.article-body blockquote{
  margin: 0 0 1em; padding: 4px 16px; border-left: 3px solid var(--blue-500);
  background: var(--bg-alt); border-radius: 0 8px 8px 0; color: var(--ink-soft);
}
.article-body blockquote p:last-child{ margin-bottom:0; }
.article-body hr{ border:none; border-top:1px solid var(--line); margin: 2em 0; }
.article-body img{ max-width:100%; border-radius:8px; }
.article-body table{
  display:block; overflow-x:auto; -webkit-overflow-scrolling:touch;
  width:100%; border-collapse:collapse; margin: 0 0 1.4em; font-size:14px;
}
.article-body th, .article-body td{
  border:1px solid var(--line); padding:8px 14px; text-align:left; white-space:nowrap;
}
.article-body thead th{
  background: var(--blue-700); color:#fff; font-family: var(--font-display);
  font-weight:600; font-size:13px;
}
.article-body tbody tr:nth-child(even){ background: var(--bg-alt); }
.article-body tbody tr:hover{ background: rgba(28,167,222,0.12); }

/* ---------- Error pages (error/401.html, 403.html, 404.html, 500.html) ---------- */
.error-page{
  min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px;
}
.error-card{
  background: var(--surface); border:1px solid var(--line); border-radius:16px;
  padding:44px 32px; max-width:420px; width:100%; text-align:center;
}
.error-card .chrome-mark{ margin:0 auto 22px; }
.error-code{
  font-family: var(--font-display); font-size:48px; font-weight:700;
  color: var(--blue-600); margin:0 0 6px; line-height:1;
}
.error-card h1{ font-size:19px; margin-bottom:10px; }
.error-desc{ font-size:13.5px; color: var(--ink-soft); margin:0 0 26px; }
.error-actions{ display:flex; gap:10px; flex-wrap:wrap; justify-content:center; }
.error-actions button, .error-actions a{
  padding:10px 18px; border-radius:8px; font-size:13.5px; font-weight:600; cursor:pointer;
  font-family: var(--font-body); border:1px solid var(--line); background: var(--surface); color: var(--ink);
}
.error-actions .btn-primary{ background: var(--blue-500); border-color: var(--blue-500); color:#fff; }
.error-actions .btn-primary:hover{ background: var(--blue-600); border-color: var(--blue-600); }
.error-actions a:hover, .error-actions button:hover{ border-color: var(--blue-500); color: var(--blue-700); }
.error-actions .btn-primary:hover{ color:#fff; }
.article-not-found{
  background: var(--surface); border:1px dashed var(--line); border-radius: var(--radius);
  padding: 40px 16px; text-align:center; color: var(--ink-soft); margin-bottom: 30px;
}

/* ---------- Desktop layout ---------- */
@media (min-width: 960px){
  .header-nav-pc{ display:flex; }
  .hamburger{ display:none; }

  .layout{
    display:grid;
    grid-template-columns: var(--side-w) 1fr var(--right-w);
    gap: 24px;
    align-items:start;
  }
  .side-menu{
    position: sticky; top: calc(var(--header-h) + 20px);
    left:auto; height:auto; max-width:none; width:auto;
    transform:none; box-shadow:none; border:1px solid var(--line);
    border-radius: var(--radius); padding:16px;
    margin-top:28px;
  }
  .side-menu-close{ display:none; }
  .menu-overlay{ display:none; }
  .article-grid{ grid-template-columns: 1fr 1fr; }
  .side-right{ margin-top:28px; }
  .mobile-footer-nav{ display:none; }
}

@media (min-width:1280px){
  .article-grid{ grid-template-columns: 1fr 1fr; }
}

/* ---------- Mobile-only footer menu button ---------- */
@media (max-width: 959px){
  .site-footer{ padding-bottom: 84px; }
  .mobile-footer-nav{
    display:grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom:0; left:0; right:0;
    height: var(--footer-h); background: var(--surface);
    border-top:1px solid var(--line); z-index: 45;
  }
  .mobile-footer-nav a,
  .mobile-footer-nav button{
    display:flex; flex-direction:column; align-items:center; justify-content:center;
    gap:2px; background:none; border:none; color: var(--ink-soft);
    font-size:10.5px; font-weight:500; padding:6px 2px; position:relative;
  }
  .mobile-footer-nav svg{ width:20px; height:20px; stroke: var(--ink-soft); fill:none; stroke-width:1.8; }
  .mobile-footer-nav .tab-active{ color: var(--blue-700); }
  .mobile-footer-nav .tab-active svg{ stroke: var(--blue-500); }
  .mobile-footer-nav .tab-active::before{
    content:""; position:absolute; top:0; left:50%; transform:translateX(-50%);
    width:22px; height:2px; background: var(--amber-400); border-radius:2px;
  }
  .side-right .ad-widget{ display:none; }
}
