/* nekoy3.net — ターミナル風ブログ
   配色は html[data-theme] の変数で切り替える。cyber が既定、green と amber が選べる。 */

:root {
  --bg: #07060e;
  --panel: #0c0a18;
  --line: #1f2a44;
  --fg: #d4f3f8;
  --hi: #62f3ff;
  --acc: #ff45ee;
  --dim: #6aa0ad;
  --err: #ff5d73;
  --c-kw: #ff6af0;
  --c-str: #b8f77a;
  --c-num: #ffc66d;
  --c-fn: #62f3ff;
  --c-com: #5f7f95;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, "Noto Sans Mono CJK JP", monospace;
  --pixel: "DotGothic16", "JetBrains Mono", ui-monospace, Menlo, monospace;
  --sans: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
  --glow: 0 0 .55em color-mix(in srgb, var(--hi) 55%, transparent);
  --glow-acc: 0 0 .55em color-mix(in srgb, var(--acc) 55%, transparent);
  --veil: 74%;        /* 本文の下に敷く幕の濃さ。記事ページでは濃くする */
  --crt: .85;         /* 走査線の濃さ */
  --bg-alpha: .6;     /* 動く背景の濃さ */
  --bar-h: 30px;
}
html[data-theme="green"] {
  --bg: #040a05;
  --panel: #07120a;
  --line: #17351f;
  --fg: #c8f7d2;
  --hi: #35ff6b;
  --acc: #eaff5a;
  --dim: #4fae6b;
  --c-kw: #eaff5a;
  --c-str: #8dffb0;
  --c-num: #ffd27a;
  --c-fn: #35ff6b;
  --c-com: #3f7d52;
}
html[data-theme="amber"] {
  --bg: #0b0703;
  --panel: #140c05;
  --line: #3a2710;
  --fg: #ffe0a6;
  --hi: #ffb21a;
  --acc: #ff7a3c;
  --dim: #b98a3a;
  --c-kw: #ff7a3c;
  --c-str: #ffe08a;
  --c-num: #ffd0a0;
  --c-fn: #ffb21a;
  --c-com: #8a6a34;
}
html[data-fx="off"] { --glow: none; --glow-acc: none; }
body.k-post, body.k-page { --veil: 95%; --crt: .45; --bg-alpha: .22; }
body.k-admin { --veil: 96%; --crt: .35; --bg-alpha: .15; }

*, *::before, *::after { box-sizing: border-box; }
html {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 1.5rem;
  scroll-padding-bottom: 4rem;
  scrollbar-color: var(--line) var(--bg);
  scrollbar-width: thin;
}
body { margin: 0; min-height: 100vh; min-height: 100dvh; overflow-wrap: anywhere; }
::selection { background: var(--acc); color: var(--bg); text-shadow: none; }
a { color: var(--hi); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .2em; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, h4 { font-family: var(--pixel); font-weight: 400; line-height: 1.35; text-wrap: balance; }
kbd {
  font-family: var(--mono); font-size: .85em; padding: .05em .45em;
  border: 1px solid var(--dim); border-bottom-width: 2px; border-radius: 3px; color: var(--fg);
}
.skip { position: fixed; left: -999px; top: 0; z-index: 200; background: var(--hi); color: var(--bg); padding: .4em 1em; }
.skip:focus { left: 0; }

/* ---------- 背景 / CRT ---------- */
#bg {
  position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none;
  opacity: var(--bg-alpha);
  background-image: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--hi) 30%, transparent) 1px, transparent 1.6px);
  background-size: 32px 32px;
}
.crt {
  position: fixed; inset: 0; z-index: 60; pointer-events: none; overflow: hidden;
  opacity: var(--crt);
  background:
    repeating-linear-gradient(to bottom, transparent 0, transparent 2px, rgba(0, 0, 0, .24) 3px, transparent 4px),
    radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, .5) 100%);
}
.crt::after {
  content: ""; position: absolute; left: 0; right: 0; top: -30vh; height: 24vh;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--hi) 6%, transparent), transparent);
  animation: sweep 11s linear infinite;
}
body.k-post .crt::after, body.k-page .crt::after, body.k-admin .crt::after { display: none; }
@keyframes sweep { to { transform: translateY(160vh); } }
html[data-fx="off"] .crt, html[data-fx="off"] #bg, html[data-fx="off"] .spot, html[data-fx="off"] .floor { display: none; }

/* カーソルのまわりだけ点の格子が明るくなる (記事ページでは出さない) */
.spot {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0; transition: opacity .5s;
  background:
    radial-gradient(circle at 1px 1px, var(--hi) 1.1px, transparent 1.8px) 0 0 / 32px 32px,
    color-mix(in srgb, var(--hi) 10%, transparent);
  -webkit-mask-image: radial-gradient(circle 200px at var(--mx, -999px) var(--my, -999px), #000, transparent);
  mask-image: radial-gradient(circle 200px at var(--mx, -999px) var(--my, -999px), #000, transparent);
}
.spot.is-on { opacity: 1; }

/* ホームの下端にだけ敷く、奥へ流れる床 */
.floor {
  position: fixed; left: 0; right: 0; bottom: 0; height: 36vh; z-index: 0; pointer-events: none; overflow: hidden;
  perspective: 420px; perspective-origin: 50% 0; opacity: .5;
  -webkit-mask-image: linear-gradient(to bottom, transparent 4%, #000 90%);
  mask-image: linear-gradient(to bottom, transparent 4%, #000 90%);
}
.floor::before {
  content: ""; position: absolute; left: -60%; right: -60%; top: 0; height: 440px;
  transform-origin: 50% 0; transform: rotateX(72deg);
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--hi) 55%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--acc) 55%, transparent) 1px, transparent 1px);
  background-size: 40px 40px; background-position: 50% 0;
  animation: floor 2.4s linear infinite;
}
@keyframes floor {
  from { transform: rotateX(72deg) translateY(-40px); }
  to { transform: rotateX(72deg) translateY(0); }
}

/* ---------- 骨組み ---------- */
.shell {
  position: relative; z-index: 1;
  max-width: 60rem; margin: 0 auto;
  padding: 1.25rem 1.25rem calc(var(--bar-h) + 2.5rem);
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--bg) var(--veil), transparent);
  border-inline: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
main { flex: 1; display: block; }

.prompt {
  font-size: .95rem; line-height: 1.7; padding-bottom: .9rem; margin-bottom: 1.4rem;
  border-bottom: 1px dashed var(--line);
  min-height: calc(1.7em + .9rem);
}
.ps1 { color: inherit; text-decoration: none !important; }
.ps1-user { color: var(--acc); text-shadow: var(--glow-acc); }
.ps1-at, .ps1-sep { color: var(--dim); }
.ps1-host { color: var(--hi); text-shadow: var(--glow); }
.ps1-cwd { color: var(--fg); }
.ps1-sym { color: var(--acc); margin: 0 .5em 0 .15em; }
.ps1-cmd { color: var(--fg); white-space: pre-wrap; }
.cursor {
  display: inline-block; width: .6em; height: 1.15em; margin-left: .1em; vertical-align: text-bottom;
  background: var(--hi); box-shadow: var(--glow);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.foot {
  margin-top: 3rem; padding-top: .9rem; border-top: 1px dashed var(--line);
  display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; justify-content: space-between;
  font-size: .8rem; color: var(--dim);
}
.foot-links { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; }
.foot a { color: var(--dim); }
.foot a:hover { color: var(--hi); }

/* ---------- tmux 風の下部バー ---------- */
.tmux {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: var(--bar-h); display: flex; align-items: stretch; gap: .25rem;
  font-size: .8rem; line-height: var(--bar-h); white-space: nowrap;
  background: color-mix(in srgb, var(--hi) 13%, var(--bg));
  border-top: 1px solid color-mix(in srgb, var(--hi) 45%, transparent);
  color: var(--fg);
}
.tmux::before {   /* 記事の読了位置 */
  content: ""; position: absolute; left: 0; top: -2px; height: 2px;
  width: calc(var(--progress, 0) * 100%); background: var(--acc); box-shadow: var(--glow-acc);
}
.tmux-session { background: var(--hi); color: var(--bg); padding: 0 .7em; font-weight: 700; }
.tmux-wins { display: flex; }
.tmux-wins a { color: var(--fg); padding: 0 .65em; text-decoration: none; }
.tmux-wins a b { font-weight: 400; color: var(--dim); }
.tmux-wins a:hover { background: color-mix(in srgb, var(--hi) 28%, transparent); }
.tmux-wins a.is-current { background: var(--acc); color: var(--bg); }
.tmux-wins a.is-current b { color: var(--bg); }
.tmux-wins a.is-current::after { content: "*"; }
.tmux-right { margin-left: auto; display: flex; align-items: stretch; }
.tmux-right button { padding: 0 .6em; color: var(--fg); }
.tmux-right button:hover { background: color-mix(in srgb, var(--hi) 28%, transparent); }
.tmux-right button b { font-weight: 400; color: var(--hi); }
.tmux-right .sw { display: inline-block; width: .7em; height: .7em; margin-right: .45em; background: linear-gradient(135deg, var(--hi) 50%, var(--acc) 50%); }
.tmux-progress { padding: 0 .7em; color: var(--dim); }
.tmux-clock { padding: 0 .8em; background: color-mix(in srgb, var(--hi) 24%, var(--bg)); }

.help {
  background: var(--panel); color: var(--fg); border: 1px solid var(--hi); padding: 1.2rem 1.5rem;
  max-width: min(34rem, calc(100vw - 2rem)); box-shadow: 0 0 2.5rem color-mix(in srgb, var(--hi) 25%, transparent);
  font-size: .9rem;
}
.help::backdrop { background: rgba(0, 0, 0, .7); }
.help h2 { margin: 0 0 .8rem; font-size: 1.15rem; color: var(--hi); text-shadow: var(--glow); }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1.2rem; margin: 0 0 1rem; }
.help dt { color: var(--acc); white-space: nowrap; }
.help dd { margin: 0; font-family: var(--sans); }
.help button { color: var(--hi); }
.help button:hover { background: var(--hi); color: var(--bg); }

/* ---------- グリッチ ---------- */
.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after {
  content: attr(data-text); position: absolute; left: 0; top: 0; width: 100%;
  opacity: 0; pointer-events: none; text-shadow: none;
}
.glitch.is-glitching, a:hover > .glitch { animation: gl-main .42s steps(1) both; }
.glitch.is-glitching::before, a:hover > .glitch::before { color: var(--acc); animation: gl-a .42s steps(1) both; }
.glitch.is-glitching::after, a:hover > .glitch::after { color: var(--hi); animation: gl-b .42s steps(1) both; }
@keyframes gl-main {
  0% { transform: translate(1px, 0) skewX(-4deg); }
  25% { transform: translate(-1px, 0); }
  50% { transform: translate(0, 0) skewX(3deg); }
  75%, 100% { transform: none; }
}
@keyframes gl-a {
  0% { opacity: .9; transform: translate(calc(var(--gx, 4px) * -1), 0); clip-path: inset(8% 0 60% 0); }
  20% { opacity: .9; transform: translate(var(--gx, 4px), -1px); clip-path: inset(58% 0 6% 0); }
  40% { opacity: .9; transform: translate(calc(var(--gx, 4px) * -.75), 1px); clip-path: inset(30% 0 38% 0); }
  60% { opacity: .9; transform: translate(calc(var(--gx, 4px) * .5), 0); clip-path: inset(72% 0 12% 0); }
  80%, 100% { opacity: 0; }
}
@keyframes gl-b {
  0% { opacity: .8; transform: translate(var(--gx, 4px), 1px); clip-path: inset(62% 0 10% 0); }
  20% { opacity: .8; transform: translate(calc(var(--gx, 4px) * -1), 0); clip-path: inset(12% 0 66% 0); }
  40% { opacity: .8; transform: translate(calc(var(--gx, 4px) * .75), -1px); clip-path: inset(44% 0 30% 0); }
  60% { opacity: .8; transform: translate(calc(var(--gx, 4px) * -.5), 0); clip-path: inset(4% 0 82% 0); }
  80%, 100% { opacity: 0; }
}
html[data-fx="off"] .glitch, html[data-fx="off"] .glitch::before, html[data-fx="off"] .glitch::after { animation: none !important; }

/* ---------- 起動シーケンス ---------- */
.boot { display: none; }
html.booting { overflow: hidden; }
html.booting .boot {
  display: block; position: fixed; inset: 0; z-index: 55; background: var(--bg);
  padding: 1.2rem 1.4rem; overflow: hidden; cursor: pointer;
}
html.booting .tmux { visibility: hidden; }
.boot pre { margin: 0; font: inherit; font-size: .85rem; line-height: 1.55; white-space: pre-wrap; color: var(--fg); }
.boot .ok { color: var(--hi); text-shadow: var(--glow); }
.boot .ts { color: var(--dim); }
.boot .big { color: var(--acc); text-shadow: var(--glow-acc); }
.boot-skip { position: absolute; right: 1.4rem; bottom: 1rem; margin: 0; font-size: .75rem; color: var(--dim); animation: blink 1.4s steps(1) infinite; }
html.boot-out .boot { animation: crt-on .45s cubic-bezier(.7, 0, .3, 1) forwards; }
@keyframes crt-on {
  0% { transform: none; filter: brightness(1); opacity: 1; }
  45% { transform: scaleY(.006); filter: brightness(4); opacity: 1; }
  80% { transform: scaleY(.006) scaleX(.0); filter: brightness(8); opacity: 1; }
  100% { transform: scaleY(.006) scaleX(0); opacity: 0; }
}

/* ---------- home ---------- */
body.k-home .shell { max-width: 66rem; }
.hero {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.5rem 2rem; align-items: center;
  margin: .2rem 0 2.8rem; padding: 1.5rem 1.5rem 1.3rem;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--hi) 7%, transparent), transparent 55%);
}
.hero::before {   /* 四隅の かぎ括弧 */
  content: ""; position: absolute; inset: -1px; pointer-events: none;
  --b: linear-gradient(var(--hi), var(--hi));
  background:
    var(--b) left top / 18px 2px no-repeat, var(--b) left top / 2px 18px no-repeat,
    var(--b) right top / 18px 2px no-repeat, var(--b) right top / 2px 18px no-repeat,
    var(--b) left bottom / 18px 2px no-repeat, var(--b) left bottom / 2px 18px no-repeat,
    var(--b) right bottom / 18px 2px no-repeat, var(--b) right bottom / 2px 18px no-repeat;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--hi) 60%, transparent));
}
.hero-text { position: relative; z-index: 1; min-width: 0; }
.hero-kicker {
  margin: 0 0 .55rem; display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .7em;
  font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
}
.hero-kicker b { font-weight: 400; color: var(--fg); font-variant-numeric: tabular-nums; }
.hero-kicker .sep { color: var(--line); }
.led {
  width: .62em; height: .62em; border-radius: 50%; background: var(--c-str);
  box-shadow: 0 0 .7em var(--c-str); animation: led 2.4s ease-in-out infinite;
}
@keyframes led { 50% { opacity: .35; } }
.hero-title {
  --gx: 10px;
  margin: 0; font-size: clamp(2.9rem, 13.5vw, 6rem); line-height: 1.05; white-space: nowrap; color: var(--fg);
  text-shadow:
    .035em 0 0 color-mix(in srgb, var(--acc) 85%, transparent),
    -.035em 0 0 color-mix(in srgb, var(--hi) 85%, transparent),
    0 0 .45em color-mix(in srgb, var(--hi) 45%, transparent);
}
html[data-fx="off"] .hero-title { color: var(--hi); text-shadow: none; }
.hero-rule {
  height: 2px; margin: .75rem 0 0; width: min(100%, 31rem);
  background: linear-gradient(90deg, var(--acc), var(--hi) 45%, transparent);
  box-shadow: 0 0 .6rem color-mix(in srgb, var(--hi) 50%, transparent);
}
.hero-tag { margin: .85rem 0 0; min-height: 1.7em; font-family: var(--sans); font-size: 1rem; color: var(--fg); }
.hero-tag .ps1-sym { font-family: var(--mono); margin-left: 0; }
.hero-row { display: flex; align-items: center; gap: 1.5rem; margin-top: 1.3rem; }
.cat {
  margin: 0; font: inherit; font-size: 1.05rem; line-height: 1.25; color: var(--hi); text-shadow: var(--glow);
  flex: none; user-select: none;
}
.cat-eyes { color: var(--acc); text-shadow: var(--glow-acc); }
.stats { display: flex; flex-wrap: wrap; gap: .7rem 0; margin: 0; }
.stat { padding: 0 1.1rem; border-left: 1px solid var(--line); }
.stat dt { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.stat dd {
  margin: 0; font-family: var(--pixel); font-size: 1.7rem; line-height: 1.25; white-space: nowrap;
  color: var(--hi); text-shadow: var(--glow); font-variant-numeric: tabular-nums;
}
.stat dd small { font-size: .5em; margin-left: .25em; color: var(--dim); text-shadow: none; }
.hero-hint { margin: 1.2rem 0 0; font-family: var(--sans); font-size: .78rem; color: var(--dim); }
.hero-globe { width: clamp(260px, 30vw, 340px); }
.hero-globe canvas { display: block; width: 100%; height: auto; aspect-ratio: 1; cursor: grab; touch-action: pan-y; }
.hero-globe canvas.is-drag { cursor: grabbing; }
.globe-cap { margin: .2rem 0 0; text-align: center; font-size: .72rem; letter-spacing: .1em; color: var(--dim); white-space: pre; }
@media (min-width: 861px) {
  .hero-title { font-size: min(6rem, calc((100vw - 30rem) / 5.3)); }
}

/* 読み込み直後に、上から順に立ち上がる */
html:not(.booting) .k-home main > section { animation: rise .55s cubic-bezier(.2, .7, .2, 1) both; }
html:not(.booting) .k-home main > section:nth-child(2) { animation-delay: .1s; }
html:not(.booting) .k-home main > section:nth-child(3) { animation-delay: .2s; }
html:not(.booting) .k-home main > section:nth-child(4) { animation-delay: .3s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* 投稿の記録 (草) */
.heat-grid { display: flex; gap: 3px; overflow: hidden; padding: 2px 0; }
.heat-col { display: grid; gap: 3px; flex: 1 1 0; min-width: 0; }
.heat-col i, .heat-legend i { display: block; background: color-mix(in srgb, var(--hi) 9%, transparent); }
.heat-col i { aspect-ratio: 1; }
.heat-legend i { width: 12px; height: 12px; }
html:not(.booting) .heat-col i { animation: cell .35s both; animation-delay: calc(.3s + var(--c) * 14ms); }
@keyframes cell { from { opacity: 0; transform: scale(.2); } }
.heat-col i.x { background: none; }
.heat i.l1 { background: color-mix(in srgb, var(--hi) 45%, transparent); }
.heat i.l2 { background: color-mix(in srgb, var(--hi) 80%, transparent); box-shadow: 0 0 6px color-mix(in srgb, var(--hi) 60%, transparent); }
.heat i.l3 { background: var(--acc); box-shadow: 0 0 8px color-mix(in srgb, var(--acc) 70%, transparent); }
.heat-col i:not(.x):hover { outline: 1px solid var(--fg); }
.heat-foot { margin: .5rem 0 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .3rem 1rem; font-size: .78rem; color: var(--dim); }
.heat-legend { display: inline-flex; align-items: center; gap: 3px; }
.heat-legend i:first-child { margin-left: .5em; }
.heat-legend i:last-child { margin-right: .5em; }

.sub-prompt { margin: 2.2rem 0 .5rem; color: var(--fg); font-size: .95rem; }
.tags-inline { margin: 0; display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; }
.tags-inline sup { color: var(--dim); margin-left: .15em; font-size: .7em; }

/* ---------- 一覧 (ls -l 風) ---------- */
.page-h { margin: 0 0 .2rem; font-size: 1.5rem; color: var(--hi); text-shadow: var(--glow); }
.ls-total { margin: 0 0 .6rem; color: var(--dim); font-size: .85rem; }
.files { list-style: none; margin: 0; padding: 0; }
.file { margin: 0 0 .55rem; }
.file > a {
  display: grid; grid-template-columns: auto auto 3.6em 1fr; gap: 0 1.1em; align-items: baseline;
  padding: .12rem .45rem; margin: 0 -.45rem; color: var(--fg); text-decoration: none;
  background: linear-gradient(var(--hi), var(--hi)) left / 0% 100% no-repeat;
  transition: background-size .16s steps(8);
}
.f-perm { color: var(--dim); font-size: .85rem; }
.f-date { color: var(--dim); font-size: .85rem; white-space: nowrap; }
.f-size { color: var(--dim); font-size: .85rem; text-align: right; white-space: nowrap; }
.f-name { font-family: var(--pixel); font-size: 1.12rem; color: var(--hi); text-shadow: var(--glow); }
.file > a:hover, .file > a:focus-visible, .file.is-cursor > a {
  background-size: 100% 100%; color: var(--bg); outline: none;
  box-shadow: -4px 0 0 var(--acc), 0 0 1.4rem color-mix(in srgb, var(--hi) 35%, transparent);
}
html[data-fx="off"] .file > a { transition: none; }
html[data-fx="off"] .file > a:hover, html[data-fx="off"] .file > a:focus-visible, html[data-fx="off"] .file.is-cursor > a { box-shadow: none; }
.file > a:hover *, .file > a:focus-visible *, .file.is-cursor > a * { color: var(--bg); text-shadow: none; }
.f-sum {
  margin: .1rem 0 0; padding-left: 1.1em; border-left: 1px solid var(--line);
  font-family: var(--sans); font-size: .86rem; line-height: 1.6; color: color-mix(in srgb, var(--fg) 72%, var(--bg));
}
.f-tags a { font-family: var(--mono); font-size: .8rem; color: var(--acc); margin-left: .6em; white-space: nowrap; }
.ls-more { margin: 1.4rem 0 0; display: flex; gap: 1.5rem; flex-wrap: wrap; }
.empty { color: var(--dim); font-family: var(--sans); }
.year { margin: 1.6rem 0 .5rem; font-size: 1rem; color: var(--acc); display: flex; align-items: center; gap: .8rem; }
.year::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
.grep { display: flex; align-items: center; gap: .2em; margin: .2rem 0 .4rem; font-size: .9rem; color: var(--fg); }
.grep input {
  flex: 1; min-width: 0; max-width: 22rem; font: inherit; color: var(--hi); background: transparent;
  border: 0; border-bottom: 1px solid var(--line); padding: .15em .3em; margin-left: .4em; border-radius: 0;
}
.grep input:focus { outline: none; border-bottom-color: var(--hi); }
.grep input::placeholder { color: color-mix(in srgb, var(--dim) 70%, transparent); }
.tagdir { list-style: none; margin: 0; padding: 0; }
.tagdir a { display: grid; grid-template-columns: auto 2.5em 1fr; gap: 0 1.1em; padding: .12rem .45rem; margin: 0 -.45rem; color: var(--fg); text-decoration: none; }
.tagdir a:hover, .tagdir a:focus-visible { background: var(--hi); color: var(--bg); outline: none; }
.tagdir a:hover *, .tagdir a:focus-visible * { color: var(--bg); text-shadow: none; }

/* ---------- 記事 ---------- */
.post-head { margin-bottom: 1.6rem; }
.post-title { margin: 0 0 .5rem; font-size: clamp(1.55rem, 5vw, 2.3rem); color: var(--hi); text-shadow: var(--glow); }
.post-meta { margin: 0; font-size: .85rem; color: var(--dim); }
.post-meta .sep { color: var(--line); margin: 0 .3em; }
.post-meta a { color: var(--acc); }
.preview-banner { margin: 0 0 1.2rem; padding: .4rem .8rem; border: 1px dashed var(--acc); color: var(--acc); font-size: .85rem; }
.preview-banner a { margin-left: 1em; }

.toc { margin: 0 0 1.8rem; font-size: .85rem; border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 85%, transparent); }
.toc summary { cursor: pointer; padding: .45rem .8rem; color: var(--dim); list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc[open] summary { border-bottom: 1px dashed var(--line); }
.toc ol { list-style: none; margin: 0; padding: .5rem .8rem .7rem; }
.toc li { margin: .15rem 0; }
.toc a { color: color-mix(in srgb, var(--fg) 75%, var(--bg)); font-family: var(--sans); display: block; padding-left: .6em; border-left: 2px solid transparent; }
.toc a:hover { color: var(--hi); text-decoration: none; }
.toc a.is-active { color: var(--hi); border-left-color: var(--acc); }
.toc .toc-l3 a { padding-left: 1.6em; }
.toc .toc-l4 a { padding-left: 2.6em; }

.md { font-family: var(--sans); font-size: 1rem; line-height: 1.95; color: var(--fg); }
.md > :first-child { margin-top: 0; }
.md p { margin: 1.15em 0; }
.md h2, .md h3, .md h4 { position: relative; color: var(--hi); text-shadow: var(--glow); margin: 2.6em 0 .8em; }
.md h2 { font-size: 1.5rem; padding-bottom: .3em; border-bottom: 1px dashed var(--line); }
.md h3 { font-size: 1.25rem; }
.md h4 { font-size: 1.08rem; }
.md h2::before { content: "## "; color: var(--acc); text-shadow: var(--glow-acc); }
.md h3::before { content: "### "; color: var(--acc); text-shadow: var(--glow-acc); }
.md h4::before { content: "#### "; color: var(--acc); text-shadow: var(--glow-acc); }
.md .header-anchor { margin-left: .5em; color: var(--dim); opacity: 0; text-shadow: none; text-decoration: none; transition: opacity .15s; }
.md :is(h2, h3, h4):hover .header-anchor, .md .header-anchor:focus-visible { opacity: 1; }
.md a { color: var(--hi); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--hi) 45%, transparent); text-underline-offset: .22em; }
.md a:hover { background: var(--hi); color: var(--bg); text-decoration: none; }
.md strong { color: #fff; font-weight: 700; }
html[data-theme="amber"] .md strong { color: #fff3d6; }
.md em { font-style: italic; }
.md del { color: var(--dim); }
.md mark { background: color-mix(in srgb, var(--acc) 35%, transparent); color: inherit; }
.md ul, .md ol { padding-left: 1.6em; margin: 1.1em 0; }
.md li { margin: .3em 0; }
.md li > ul, .md li > ol { margin: .3em 0; }
.md ul { list-style: none; }
.md ul > li { position: relative; }
.md ul > li::before { content: "-"; position: absolute; left: -1.15em; color: var(--acc); font-family: var(--mono); }
.md ol > li::marker { color: var(--acc); font-family: var(--mono); }
.md li.task-list-item::before { content: none; }
.md li.task-list-item { margin-left: -1.3em; }
.md input[type="checkbox"] { accent-color: var(--hi); margin-right: .5em; }
.md hr { border: 0; margin: 2.6em 0; text-align: center; color: var(--dim); font-family: var(--mono); }
.md hr::before { content: "* * *"; letter-spacing: .6em; }
.md img, .md video { max-width: 100%; height: auto; display: block; margin: 1.5em auto; border: 1px solid var(--line); }
.md iframe { max-width: 100%; border: 1px solid var(--line); }
.md blockquote {
  margin: 1.4em 0; padding: .1em 1.1em; border-left: 3px solid var(--dim);
  color: color-mix(in srgb, var(--fg) 78%, var(--bg)); background: color-mix(in srgb, var(--panel) 80%, transparent);
}
.md blockquote.alert { --tone: var(--hi); border: 1px solid color-mix(in srgb, var(--tone) 55%, transparent); border-left: 3px solid var(--tone); padding: 2.1em 1.1em .2em; position: relative; color: var(--fg); }
.md blockquote.alert::before {
  content: "[" attr(data-label) "]"; position: absolute; left: 1.1em; top: .55em;
  font-family: var(--mono); font-size: .8rem; line-height: 1.4; color: var(--tone);
}
.md blockquote.alert-tip { --tone: var(--c-str); }
.md blockquote.alert-important { --tone: var(--acc); }
.md blockquote.alert-warning { --tone: var(--c-num); }
.md blockquote.alert-caution { --tone: var(--err); }
.md :not(pre) > code {
  font-family: var(--mono); font-size: .88em; padding: .12em .4em; border-radius: 2px;
  background: color-mix(in srgb, var(--hi) 11%, transparent); color: var(--c-num);
}
.md a > code { color: inherit; }
.table-wrap { overflow-x: auto; margin: 1.5em 0; }
.md table { border-collapse: collapse; font-size: .92rem; line-height: 1.6; min-width: 50%; }
.md th, .md td { border: 1px solid var(--line); padding: .4em .9em; text-align: left; vertical-align: top; }
.md th { background: color-mix(in srgb, var(--hi) 11%, transparent); color: var(--hi); font-family: var(--mono); font-weight: 400; white-space: nowrap; }
.md tbody tr:hover td { background: color-mix(in srgb, var(--hi) 5%, transparent); }
.md dt { color: var(--hi); font-family: var(--mono); margin-top: 1em; }
.md dd { margin: .2em 0 0 1.5em; }
.md .footnotes { margin-top: 3em; padding-top: 1em; border-top: 1px dashed var(--line); font-size: .88rem; color: color-mix(in srgb, var(--fg) 80%, var(--bg)); }
.md .footnotes hr { display: none; }
.md .footnote-ref a, .md .footnote-backref { text-decoration: none; font-family: var(--mono); }

/* コードブロック */
figure.code {
  margin: 1.6em 0; border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 92%, #000);
  font-family: var(--mono);
}
figure.code figcaption {
  display: flex; align-items: center; gap: .8em; min-height: 1.9rem;
  border-bottom: 1px solid var(--line); font-size: .76rem; line-height: 1.9rem; color: var(--dim);
}
.code-lang { background: var(--line); color: var(--fg); padding: 0 .8em; text-transform: lowercase; }
.code-file { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-copy { margin-left: auto; padding: 0 .9em; color: var(--dim); font-size: .76rem; line-height: 1.9rem; }
.code-copy:hover, .code-copy:focus-visible { background: var(--hi); color: var(--bg); }
.code-copy.is-done { color: var(--c-str); }
figure.code pre {
  margin: 0; padding: .9rem 1rem; overflow-x: auto; font-family: var(--mono); font-size: .86rem; line-height: 1.65;
  tab-size: 2; color: var(--fg); scrollbar-color: var(--line) transparent; scrollbar-width: thin;
  overflow-wrap: normal; white-space: pre;
}
figure.code code { font: inherit; background: none; padding: 0; color: inherit; }
.md pre .k, .md pre .kc, .md pre .kd, .md pre .kn, .md pre .kp, .md pre .kr, .md pre .kt, .md pre .ow, .md pre .nt, .md pre .cp { color: var(--c-kw); }
.md pre .s, .md pre .sa, .md pre .sb, .md pre .sc, .md pre .dl, .md pre .sd, .md pre .s2, .md pre .se, .md pre .sh, .md pre .si, .md pre .sx, .md pre .sr, .md pre .s1, .md pre .ss { color: var(--c-str); }
.md pre .m, .md pre .mb, .md pre .mf, .md pre .mh, .md pre .mi, .md pre .mo, .md pre .il, .md pre .nv, .md pre .vc, .md pre .vg, .md pre .vi, .md pre .bp, .md pre .no { color: var(--c-num); }
.md pre .nf, .md pre .fm, .md pre .nc, .md pre .nd, .md pre .nb, .md pre .na, .md pre .ne, .md pre .nn { color: var(--c-fn); }
.md pre .c, .md pre .ch, .md pre .cm, .md pre .cpf, .md pre .c1, .md pre .cs, .md pre .gp, .md pre .go { color: var(--c-com); }
.md pre .c, .md pre .cm, .md pre .c1 { font-style: italic; }
.md pre .gi { color: var(--c-str); }
.md pre .gd { color: var(--err); }
.md pre .gh, .md pre .gu { color: var(--c-fn); }
.md pre .o, .md pre .p { color: color-mix(in srgb, var(--fg) 80%, var(--bg)); }

.eof { margin: 2.5rem 0 1.5rem; text-align: center; color: var(--dim); font-size: .85rem; letter-spacing: .2em; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pager a { display: block; border: 1px solid var(--line); padding: .6rem .9rem; color: var(--fg); font-family: var(--pixel); text-decoration: none; }
.pager a span { display: block; font-family: var(--mono); font-size: .76rem; color: var(--dim); }
.pager a:hover { border-color: var(--hi); box-shadow: inset 0 0 1.2rem color-mix(in srgb, var(--hi) 14%, transparent); }
.pager-newer { text-align: right; grid-column: 2; }

.notfound { padding: 2rem 0; }
.notfound .err { color: var(--err); margin: 0; }
.notfound h1 { margin: .3rem 0 .6rem; font-size: clamp(4rem, 22vw, 9rem); line-height: 1; color: var(--hi); text-shadow: var(--glow); }
.notfound p { font-family: var(--sans); }
.notfound .err, .notfound .ls-more { font-family: var(--mono); }

/* ---------- 広い画面: 目次を右に固定 ---------- */
@media (min-width: 1180px) {
  body.k-post .shell { max-width: 74rem; }
  .post:has(.toc) { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; column-gap: 2.5rem; align-items: start; }
  .post:has(.toc) > * { grid-column: 1; }
  .post:has(.toc) > .toc {
    grid-column: 2; grid-row: 1 / span 6; position: sticky; top: 1.2rem; margin: 0;
    max-height: calc(100vh - var(--bar-h) - 2.4rem); overflow-y: auto; scrollbar-width: thin;
  }
  .post:has(.toc) > .toc summary { pointer-events: none; }
}

/* ---------- 地球儀を横に置けない幅では、ヒーローの奥に薄く敷く ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr); padding: 1.2rem 1rem 1.1rem; overflow: hidden; }
  .hero-globe { position: absolute; right: -5rem; top: 50%; width: 18rem; transform: translateY(-50%); opacity: .34; z-index: 0; pointer-events: none; }
  .globe-cap { display: none; }
}

/* ---------- 狭い画面 ---------- */
@media (max-width: 640px) {
  html { font-size: 15px; }
  :root { --bar-h: 36px; }
  .shell { padding: 1rem .95rem calc(var(--bar-h) + 2rem); border-inline: 0; }
  .prompt { font-size: .85rem; }
  .cat { font-size: .82rem; }
  .hero-row { gap: 1rem; align-items: flex-start; }
  .stat { padding: 0 .8rem; }
  .stat dd { font-size: 1.35rem; }
  .heat-grid { justify-content: flex-end; }
  .heat-col { flex: none; }
  .heat-col i { width: 12px; }
  .floor { height: 24vh; }
  .file > a { grid-template-columns: auto 3.4em 1fr; gap: 0 .8em; }
  .file > a .f-name { grid-column: 1 / -1; }
  .f-perm, .tagdir .f-perm { display: none; }
  .tagdir a { grid-template-columns: 2.2em 1fr; }
  .tmux { font-size: .78rem; gap: 0; }
  .tmux-session, .tmux-clock, .tmux-progress, .tmux-right .lbl, #theme-btn b { display: none; }
  .tmux-wins a { padding: 0 .5em; }
  .tmux-right button { padding: 0 .75em; }
  .tmux-right .sw { margin-right: 0; width: .95em; height: .95em; vertical-align: -.1em; }
  .md { font-size: 1.02rem; line-height: 1.9; }
  figure.code { margin-inline: -.95rem; border-inline: 0; }
  .pager { grid-template-columns: 1fr; }
  .pager-newer { grid-column: 1; }
}

/* ---------- ページ遷移 ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .15s cubic-bezier(.7, 0, 1, 1) both; }
::view-transition-new(root) { animation: vt-in .24s cubic-bezier(0, .6, .2, 1) .13s both; }
@keyframes vt-out {
  40% { transform: translateX(-5px); filter: brightness(1.3) saturate(1.5); }
  100% { transform: scaleY(.012); filter: brightness(4); opacity: .9; }
}
@keyframes vt-in {
  0% { transform: scaleY(.012); filter: brightness(4); opacity: 0; }
  30% { opacity: 1; }
  70% { transform: none; filter: brightness(1.25); }
}
html[data-fx="off"]::view-transition-old(root), html[data-fx="off"]::view-transition-new(root) { animation: none; }

/* ---------- 動きを減らす設定 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
  .cursor { opacity: 1; }
}

@media print {
  #bg, .crt, .tmux, .prompt, .foot, .toc, .pager, .boot, .spot, .floor, .hero-globe { display: none !important; }
  html, body, .shell { background: #fff !important; color: #000 !important; }
  .md, .md * { color: #000 !important; text-shadow: none !important; }
}
