/* piyopiyo.jp — Scrapbox 風スタイル */
/* テーマ: 既定は OS 設定に従い、ヘッダーのボタンで <html data-theme="light|dark"> を
   切り替えて上書きする(localStorage に保存)。ダーク側の変数を変えるときは
   下の2ブロック(メディアクエリ内と data-theme)を両方更新すること。 */
:root {
  --bg: #eef1f5;
  --card: #ffffff;
  --text: #363c45;
  --muted: #8a939e;
  --link: #2d67c5;
  --accent: #f0b400;
  --label: color-mix(in srgb, var(--accent) 55%, var(--text));
  --danger: #c0392b;
  --border: rgba(0, 0, 0, 0.07);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.14);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171b;
    --card: #1e242b;
    --text: #dde2e8;
    --muted: #7d8894;
    --link: #82b4ff;
    --danger: #e07060;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #14171b;
  --card: #1e242b;
  --text: #dde2e8;
  --muted: #7d8894;
  --link: #82b4ff;
  --danger: #e07060;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue",
    "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  line-height: 1.8;
  font-size: 16px;
}
a {
  color: var(--link);
}

/* ---- ヘッダー ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.site-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
#theme-toggle {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 17px;
  line-height: 1;
  padding: 5px 7px;
  border-radius: 50%;
  cursor: pointer;
}
#theme-toggle:hover {
  background: color-mix(in srgb, var(--text) 10%, transparent);
}
#drafts-toggle {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--danger);
  border-radius: 999px;
  font-size: 12px;
  font-family: inherit;
  padding: 4px 12px;
  cursor: pointer;
  white-space: nowrap;
}
#drafts-toggle.hiding {
  color: var(--muted);
}
#drafts-toggle:hover {
  border-color: var(--accent);
}
#search {
  width: min(320px, 55vw);
  padding: 7px 14px;
  font-size: 14px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
}
#search:focus {
  border-color: var(--accent);
}

/* ---- カードグリッド ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 20px 40px;
}
#sentinel {
  grid-column: 1 / -1;
  height: 1px;
}
.card {
  display: flex;
  flex-direction: column;
  aspect-ratio: 1 / 1.1;
  background: var(--card);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  transition: box-shadow 0.15s ease, translate 0.15s ease;
}
.card:hover {
  box-shadow: var(--shadow-hover);
  translate: 0 -2px;
}
.card-title {
  padding: 10px 12px 4px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-shrink: 0;
}
.card-body {
  flex: 1;
  min-height: 0;
  padding: 2px 12px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.7;
  overflow: hidden;
}
.card-thumb {
  flex: 1;
  min-height: 0;
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-date {
  padding: 6px 12px 8px;
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
}
.card-note,
.card-series {
  padding: 6px 12px 0;
  font-size: 10px;
  color: var(--label);
  font-weight: 600;
  flex-shrink: 0;
}
.card-note.draft {
  color: var(--danger);
}
.draft-badge {
  color: var(--danger);
  font-weight: 600;
}
.card-chips {
  padding: 4px 10px 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex-shrink: 0;
}
.chip {
  display: inline-block;
  padding: 0 9px;
  font-size: 10.5px;
  line-height: 1.8;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-radius: 999px;
  text-decoration: none;
}
.page-total {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding-bottom: 40px;
  margin: 0;
}

/* ---- 記事ページ ---- */
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}
.article {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: clamp(20px, 5vw, 44px);
}
.article-series {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}
.article-series a {
  color: var(--label);
  text-decoration: none;
}
.article-series a:hover {
  text-decoration: underline;
}
.article-title {
  margin: 0 0 6px;
  font-size: clamp(22px, 4.5vw, 30px);
  line-height: 1.4;
}
.article-meta {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.article-slug {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--muted);
  background: color-mix(in srgb, var(--text) 6%, transparent);
  padding: 1px 8px;
  border-radius: 4px;
}
.article-body {
  font-size: 15.5px;
}
.article-body h2 {
  font-size: 20px;
  margin: 2em 0 0.6em;
  padding-left: 10px;
  border-left: 4px solid var(--accent);
  line-height: 1.5;
}
.article-body h3 {
  font-size: 17px;
  margin: 1.6em 0 0.5em;
}
.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}
.article-body .youtube-embed {
  aspect-ratio: 16 / 9;
  margin: 1em 0;
}
.article-body .youtube-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 8px;
  display: block;
}
.article-body code {
  background: color-mix(in srgb, var(--text) 8%, transparent);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
}
.article-body pre {
  background: #22272e;
  color: #dde2e8;
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.6;
}
.article-body pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 13px;
}
.article-body blockquote {
  margin: 1em 0;
  padding: 0.1em 1em;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.article-body table {
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}
.article-body th,
.article-body td {
  border: 1px solid var(--border);
  padding: 5px 12px;
  font-size: 14px;
}
.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}
.wikilink.missing {
  color: var(--muted);
  border-bottom: 1px dashed var(--muted);
  cursor: help;
}

/* ---- 関連ページ ---- */
.related {
  max-width: 760px;
  margin: 26px auto 0;
}
.related-title {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  margin: 22px 0 10px;
}
.related-grid {
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  padding: 0;
  max-width: none;
}
.related-grid .card {
  aspect-ratio: 1 / 1.05;
}

/* ---- フッター ---- */
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 30px 0 40px;
}
