/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Noto Sans JP', Meiryo, sans-serif;
  color: #333;
  line-height: 1.8;
  background: #f7f3ef;
}
a { color: #8b4513; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
header {
  background: #5c3317;
  color: #fff;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.site-title {
  font-size: 1.25rem;
  font-weight: bold;
  color: #fff;
  text-decoration: none;
}
.site-title:hover { text-decoration: none; opacity: 0.85; }

nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}
nav a {
  color: #f5deb3;
  font-size: 0.85rem;
  white-space: nowrap;
}
nav a:hover { color: #fff; text-decoration: none; }
nav a.active { color: #fff; font-weight: bold; border-bottom: 2px solid #f5deb3; }

/* ===== 2-Column Layout ===== */
.page-wrapper {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem 3rem;
  display: grid;
  grid-template-columns: 70% 30%;
  gap: 2rem;
  align-items: start;
}

.main-content {
  background: #fff;
  padding: 1.5rem 2rem;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  min-width: 0; /* prevent grid blowout */
}

/* ===== Sidebar ===== */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.sidebar-block {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 1rem 1.25rem;
}

.sidebar-heading {
  font-size: 0.95rem;
  font-weight: bold;
  color: #fff;
  background: #7a4520;
  margin: -1rem -1.25rem 0.75rem;
  padding: 0.45rem 1rem;
  border-radius: 4px 4px 0 0;
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.sidebar-nav li::before {
  content: '▸ ';
  color: #8b4513;
  font-size: 0.75rem;
}
.sidebar-nav a {
  font-size: 0.9rem;
  color: #5c3317;
}
.sidebar-nav a:hover { text-decoration: underline; }

.sidebar-text {
  font-size: 0.88rem;
  color: #555;
  line-height: 1.7;
  margin: 0.25rem 0;
}

.sidebar-line-btn {
  display: inline-block;
  margin-top: 0.5rem;
}

/* ===== Typography ===== */
h1 { font-size: 1.8rem; color: #5c3317; margin: 1.5rem 0 1rem; line-height: 1.4; }
h2 { font-size: 1.4rem; color: #7a4520; margin: 1.5rem 0 0.75rem; border-left: 4px solid #8b4513; padding-left: 0.6rem; }
h3 { font-size: 1.15rem; color: #5c3317; margin: 1.25rem 0 0.5rem; }
h4 { font-size: 1rem; color: #7a4520; margin: 1rem 0 0.5rem; }
p { margin: 0.75rem 0; }
ruby rt { font-size: 0.6em; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}
th, td {
  border: 1px solid #ccc;
  padding: 0.5rem 0.75rem;
  text-align: left;
}
th { background: #f5e6d8; color: #5c3317; font-weight: bold; }
tr:nth-child(even) td { background: #fdf6f0; }

/* Figures */
figure { margin: 1rem 0; overflow-x: auto; }

/* Images */
img { max-width: 100%; height: auto; }

/* Utility */
.has-text-align-center { text-align: center; }
.red { color: #c0392b; }

/* Footer */
footer {
  background: #5c3317;
  color: #f5deb3;
  text-align: center;
  padding: 1.5rem;
  font-size: 0.85rem;
}
footer a { color: #f5deb3; }

/* ===== Responsive ===== */
/* 小タブレット・スマホ: 768px以下で1カラム */
@media (max-width: 768px) {
  .page-wrapper {
    grid-template-columns: 1fr;
    margin: 1rem auto;
    padding: 0 0.75rem 2rem;
    gap: 1.25rem;
  }

  /* サイドバーをメインコンテンツの下に */
  .sidebar {
    order: 1;
  }
  .main-content {
    order: 0;
    padding: 1rem 1.25rem;
  }

  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.2rem; }
  nav ul { gap: 0.25rem 0.5rem; }
  .site-title { font-size: 1rem; }
}
