/* ==========================================================================
   ありリベ攻略・備忘録 — Clean White Editorial & Wiki Design
   Synthesizing BlogBooks.net, Nintendo, Note, Zenn, Wikipedia, GameWith,
   Prydwen, HoneyHunter, Stripe Docs, GitHub Discussions, Qiita, and Muji.
   ========================================================================== */

:root {
  --bg: #f3f4f6;           /* 非常に薄いライトグレー */
  --bg-surface: #ffffff;   /* コンテンツ領域の白 */
  --bg-soft: #f7f7f9;      /* ごく薄いグレー */
  --bg-hover: #eceef2;
  --border: #e2e4e9;
  --border-strong: #cfd3dc;

  --header-bg: #22242a;    /* 濃いダークグレー（チャコール系） */
  --header-text: #f9fafb;
  --header-muted: #c2c6d0;

  --text: #1f2328;         /* 黒〜濃いグレー */
  --text-sub: #4b5563;
  --text-muted: #6b7280;

  --accent: #b91c1c;       /* 濃い赤（クリムゾン／エンジ系） */
  --accent-hover: #991b1b;
  --accent-soft: #fef2f2;
  --link: #b91c1c;
  --gold: #b45309;
  --gold-soft: #fffbeb;
  --cyan: #0369a1;
  --emerald: #047857;
  --violet: #6d28d9;

  --font-display: 'Shippori Mincho', 'Noto Serif JP', Georgia, serif;
  --font-sans: 'Noto Sans JP', 'Inter', -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

[data-theme="dark"] {
  --bg: #0e1014;
  --bg-surface: #151820;
  --bg-soft: #1c202a;
  --header-bg: #12141a;
  --bg-hover: #20242d;
  --border: #262b36;
  --border-strong: #373e4d;

  --text: #f3f4f6;
  --text-sub: #9ca3af;
  --text-muted: #6b7280;

  --accent: #ef4444;
  --accent-soft: rgba(239, 68, 68, 0.12);
  --link: #60a5fa;
  --gold: #fbbf24;
  --gold-soft: rgba(251, 191, 36, 0.12);
  --cyan: #38bdf8;
  --emerald: #34d399;
  --violet: #a78bfa;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; color: inherit; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---- Charcoal Header (mementomori001.github.io/Ariribe palette) ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  color: var(--header-text);
  border-bottom: 2px solid var(--accent);
}
.header-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  white-space: nowrap;
}
.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-link {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: 4px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 500;
  color: var(--header-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.14); color: #ffffff; }
.nav-link.active {
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}
.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.search-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 6px 16px;
  min-width: 170px;
  justify-content: space-between;
  font-size: 13px;
  color: var(--header-muted);
  cursor: pointer;
}
.search-pill:hover { border-color: rgba(255, 255, 255, 0.35); color: #ffffff; }
.theme-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--header-muted);
  cursor: pointer;
}
.theme-btn:hover { background: rgba(255, 255, 255, 0.14); color: #ffffff; }

/* ---- Page Container ---- */
.page-wrap {
  max-width: 1160px;
  margin: 22px auto 36px;
  padding: 28px 28px 56px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* ---- Unmistakable Masthead on Home (No Boxes!) ---- */
.masthead {
  padding-bottom: 24px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.masthead-kicker {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.masthead-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 27px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.masthead-desc {
  margin: 0 0 16px;
  color: var(--text-sub);
  font-size: 14.5px;
  max-width: 68ch;
}
.quick-links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.quick-link-pill {
  background: var(--bg-soft);
  border: none;
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.quick-link-pill:hover { background: var(--bg-hover); color: var(--accent); }
.quick-link-pill.primary { background: var(--accent); color: #fff; }
.quick-link-pill.primary:hover { filter: brightness(0.94); color: #fff; }

/* ---- Home 2-Column Editorial Layout (BlogBooks + Zenn/Note) ---- */
.home-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 44px;
  align-items: start;
}

.section-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--text);
  margin: 0 0 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* BlogBooks.net Style Article Feed (Zero Rectangular Boxes!) */
.article-feed-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.article-feed-item:hover .feed-title { color: var(--accent); }
.feed-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.feed-cat {
  color: var(--accent);
  font-weight: 700;
}
.feed-title {
  margin: 0 0 6px;
  font-size: 18.5px;
  font-weight: 700;
  line-height: 1.4;
  transition: color 0.12s;
}
.feed-excerpt {
  margin: 0;
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.65;
}

/* Clean Sidebar Lists (No Heavy Borders) */
.sidebar-block { margin-bottom: 32px; }
.sidebar-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 10px;
  margin-bottom: 4px;
  background: var(--bg-soft);
  border: none;
  border-left: 3px solid var(--accent);
  width: 100%;
  text-align: left;
  font-size: 13.5px;
  cursor: pointer;
}
.sidebar-list-item:hover { color: var(--accent); }

/* ---- Breadcrumb ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.breadcrumb button {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-sub);
  cursor: pointer;
  font-size: 12.5px;
}
.breadcrumb button:hover { color: var(--accent); text-decoration: underline; }

/* ---- Clean Filter Strip (No Box Wrapper) ---- */
.filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.clean-input {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13.5px;
}
.clean-input:focus { outline: none; border-color: var(--accent); background: var(--bg); }

.pill-group { display: flex; flex-wrap: wrap; gap: 4px; }
.pill {
  background: var(--bg-soft);
  border: none;
  color: var(--text-sub);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.pill:hover { background: var(--bg-hover); color: var(--text); }
.pill.active { background: var(--text); color: var(--bg); font-weight: 600; }

/* ---- Clean Horizontal-Only Tables (Wikipedia / Stripe Docs) ---- */
.table-wrap { overflow-x: auto; margin-bottom: 24px; }
table.clean-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  text-align: left;
}
table.clean-table th {
  background: var(--bg-soft);
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 700;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
table.clean-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.clean-table tbody tr.clickable { cursor: pointer; }
table.clean-table tbody tr.clickable:hover { background: var(--bg-soft); }

/* ---- Badges (Subtle, Low-Contrast) ---- */
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--text-sub);
  white-space: nowrap;
}
.attr-神 { color: var(--gold); background: var(--gold-soft); }
.attr-心 { color: var(--cyan); background: rgba(3, 105, 161, 0.09); }
.attr-夢 { color: var(--violet); background: rgba(109, 40, 217, 0.09); }
.attr-彩 { color: var(--emerald); background: rgba(4, 120, 87, 0.09); }
.attr-幻 { color: var(--accent); background: var(--accent-soft); }

/* ---- Tier Rows (Prydwen Clean) ---- */
.tier-band {
  display: grid;
  grid-template-columns: 72px 1fr;
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  align-items: start;
}
.tier-letter {
  font-size: 20px;
  font-weight: 800;
  font-family: var(--font-mono);
  padding-top: 2px;
}
.tier-SSS { color: var(--gold); }
.tier-SS { color: var(--accent); }
.tier-S { color: var(--cyan); }
.tier-A { color: var(--emerald); }
.char-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-soft);
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.char-link-chip:hover { background: var(--bg-hover); color: var(--accent); }

/* ---- Dossier View (Wikipedia Infobox + Note/Zenn Prose) ---- */
.dossier-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 36px;
  align-items: start;
}
.wiki-infobox {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-size: 13px;
}
.wiki-infobox-head {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.wiki-infobox-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.wiki-infobox-row:last-child { border-bottom: none; }

.underline-tabs {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  margin: 18px 0 16px;
}
.u-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 2px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -1px;
}
.u-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.skill-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

/* ---- Article View (Note.com + Stripe Docs Sticky TOC) ---- */
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 40px;
  align-items: start;
}
.article-body { max-width: 70ch; }
.article-body h2 {
  font-size: 19px;
  margin: 28px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.toc-sticky {
  position: sticky;
  top: 80px;
  border-left: 2px solid var(--border);
  padding-left: 14px;
  font-size: 12.5px;
}
.toc-link { display: block; color: var(--text-sub); padding: 4px 0; cursor: pointer; }
.toc-link:hover { color: var(--accent); }

.callout {
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 13.5px;
}
.callout.gold { background: var(--gold-soft); border-left-color: var(--gold); }

.formation-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.formation-slot {
  background: var(--bg-soft);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12.5px;
}

/* ---- Forum (GitHub Discussions Clean List) ---- */
.thread-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.upvote-btn {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
}
.upvote-btn:hover { border-color: var(--accent); color: var(--accent); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-soft {
  background: var(--bg-soft);
  border: none;
  color: var(--text);
  padding: 7px 13px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.btn-soft:hover { background: var(--bg-hover); }

/* ---- Command Palette Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(17, 24, 39, 0.45);
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 64px 16px;
}
.modal-backdrop.open { display: flex; }
.cmd-panel {
  width: 100%;
  max-width: 580px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }

/* Footer */
.site-footer {
  background: var(--header-bg);
  color: var(--header-muted);
  padding: 22px 28px;
  border-top: 3px solid var(--accent);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 960px) {
  .home-columns, .dossier-layout, .article-layout { grid-template-columns: 1fr; gap: 28px; }
  .toc-sticky { display: none; }
}
@media (max-width: 680px) {
  .grid-2, .formation-strip { grid-template-columns: 1fr; }
  .header-inner { gap: 10px; padding: 0 12px; }
  .page-wrap { padding: 20px 14px 56px; }
  .search-pill span.kbd { display: none; }
}

/* ---- PlayStation.com-style Full-Width Mega-Menu Drawer ---- */
.mega-drawer {
  position: fixed;
  top: 58px;
  left: 0;
  right: 0;
  z-index: 48;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 16px 36px rgba(17, 24, 39, 0.08);
  display: none;
  padding: 24px 20px 28px;
}
.mega-drawer.open { display: block; }
.mega-inner {
  max-width: 1160px;
  margin: 0 auto;
}
.mega-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}
.mega-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.mega-item:hover { background: var(--bg-soft); }
.mega-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-soft);
  display: grid;
  place-items: center;
  font-size: 16px;
  flex-shrink: 0;
}
.mega-item:hover .mega-icon { background: var(--accent-soft); color: var(--accent); }
.mega-title { font-weight: 700; font-size: 13.5px; color: var(--text); }
.mega-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.nav-caret { font-size: 10px; margin-left: 3px; opacity: 0.65; }

.masthead-search {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 520px;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  cursor: text;
}
.masthead-search:hover { border-color: var(--accent); }
