/* =========================
   Light Theme Tokens
========================= */
:root {
  --bg-color: #f6f7fb;
  --text-color: #111827;
  --muted-text: #6b7280;

  --primary-color: #2563eb;
  --primary-weak: rgba(37, 99, 235, 0.12);

  --card-bg-color: #ffffff;
  --hover-bg-color: #eef2ff;

  --border-color: #e5e7eb;
  --shadow: 0 14px 40px rgba(17, 24, 39, 0.10);

  --radius: 14px;
  --radius-sm: 10px;

  --sidebar-width: 260px;
  --toc-width: 220px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 86px;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1100px 600px at 10% -10%, rgba(37, 99, 235, 0.14), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(37, 99, 235, 0.08), transparent 55%),
    var(--bg-color);
  color: var(--text-color);
  line-height: 1.75;
}

/* Links */
a {
  color: var(--primary-color);
  text-decoration: none;
  text-underline-offset: 3px;
}

a:hover { text-decoration: underline; }

/* Headings */
h1, h2, h3 {
  color: #0f172a;
  font-weight: 650;
  line-height: 1.25;
}

h1 {
  margin: 0 0 0.9em;
  font-size: clamp(1.8rem, 2.6vw, 2.2rem);
}

h2 {
  margin-top: 2.2em;
  margin-bottom: 0.9em;
  font-size: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.35em;
}

h3 {
  margin-top: 1.8em;
  margin-bottom: 0.7em;
  font-size: 1.05rem;
}

p { margin: 0 0 1.05em; }
ul, ol { padding-left: 1.2em; }
li { margin: 0.35em 0; }

/* =========================
   Layout
========================= */
.site-container {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--toc-width);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "header header header"
    "sidebar-left main sidebar-right";
  min-height: 100vh;

  gap: 1.4rem;
  padding: 0 1.5rem 2.5rem;
  max-width: 1320px;
  margin: 0 auto;
}

/* Header */
.site-header {
  grid-area: header;
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border-color);

  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(246, 247, 251, 0.75);
  backdrop-filter: blur(10px);
}

.site-title-link { text-decoration: none; }

.site-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #0f172a;
  transition: color 0.2s;
}

.site-title-link:hover .site-title { color: var(--primary-color); }


/* =========================
   Left Sidebar (Menu)
   IMPORTANT: matches your HTML (<nav class="sidebar-left"><ul>...)
========================= */
.sidebar-left {
  grid-area: sidebar-left;
  padding-top: 1.6rem;

  position: sticky;
  top: 92px;
  align-self: start;
}

.sidebar-left ul {
  list-style: none;
  padding: 0;
  margin: 0;

  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-left a {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);

  color: var(--muted-text);
  font-weight: 700;
  border: 1px solid transparent;

  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.sidebar-left a:hover {
  background: var(--hover-bg-color);
  color: #0f172a;
  text-decoration: none;
}

.sidebar-left a.active {
  background: var(--primary-weak);
  border-color: rgba(37, 99, 235, 0.30);
  color: #0f172a;
}

/* =========================
   Main Content (Card)
========================= */
main {
  grid-area: main;

  width: 100%;
  max-width: 78ch;
  justify-self: center;

  margin-top: 1.2rem;
  padding: 2rem 2rem;

  background: var(--card-bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Anchor offset for sticky header */
main h1, main h2, main h3 { scroll-margin-top: 92px; }

.link-row { margin-top: 0.3em; }
.pill-link {
  display: inline-block;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.10);
  border: 1px solid rgba(37, 99, 235, 0.22);
  color: #1d4ed8;
  font-weight: 800;
}
.pill-link:hover { background: rgba(37, 99, 235, 0.16); text-decoration: none; }

/* Contact box */
.contact-box {
  background: var(--card-bg-color);
  padding: 1.2rem 1.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  color: var(--text-color);
}

/* =========================
   Right Sidebar (TOC)
========================= */
.sidebar-right {
  grid-area: sidebar-right;
  padding-top: 1.6rem;

  position: sticky;
  top: 92px;
  align-self: start;
}

.sidebar-right h3 {
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-text);
  border-bottom: none;
  margin: 0 0 0.75rem;
  padding-left: 0.25rem;
}

.sidebar-right ul {
  list-style: none;
  margin: 0;
  padding: 0.6rem 0;
  border-left: 1px solid var(--border-color);
}

.sidebar-right li a {
  display: block;
  padding: 0.55rem 0.9rem;
  color: var(--muted-text);
  font-size: 0.95rem;

  border-left: 3px solid transparent;
  margin-left: -1px;

  border-radius: 8px;
  transition: background-color 0.2s, color 0.2s, border-left-color 0.2s;
}

.sidebar-right li a:hover {
  color: #0f172a;
  background: var(--hover-bg-color);
  text-decoration: none;
}

.sidebar-right li a.active-toc {
  border-left-color: var(--primary-color);
  color: #0f172a;
  font-weight: 800;
}

/* =========================
   Tables
========================= */
.my-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.02em;
  margin: 1.1em 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.my-table th, .my-table td {
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  text-align: left;
}

.my-table th {
  background: rgba(37, 99, 235, 0.12);
  color: #0f172a;
  font-weight: 900;
}

.my-table tr:nth-child(even) {
  background: rgba(17, 24, 39, 0.02);
}

/* =========================
   Code blocks
========================= */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
}

pre {
  background: #0b1020;
  color: #e8eefc;
  border: 1px solid rgba(17, 24, 39, 0.18);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  overflow-x: auto;
}

pre code {
  background: transparent;
  border: 0;
  padding: 0;
  display: block;
  white-space: pre;
}

/* Existing .code-block (kept, but light-aligned header) */
.code-block {
  background-color: #0b1020;
  border: 1px solid rgba(17, 24, 39, 0.18);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 2em;
  margin-bottom: 2em;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.06);
  padding: 0.75em 1.1em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.code-block-header .lang-name {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.85em;
  font-weight: 900;
  text-transform: uppercase;
}

.code-block-header .control-btn {
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  font-size: 0.9em;
  background: none;
  border: none;
}

.code-block-header .control-btn:hover {
  color: #fff;
}

.code-block pre {
  margin: 0;
  padding: 1.1em;
}

/* Syntax colors (optional keep) */
.code-block .tag { color: #7ab7ff; }
.code-block .attr-name { color: #a6d6ff; }
.code-block .attr-value { color: #ffb38a; }
.code-t-text { color: #e8eefc; }

/* =========================
   Images
========================= */
.image-container {
  text-align: center;
  margin: 2em 0;
}

.image-container img {
  width: 420px;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.14);
  border: 1px solid var(--border-color);
  background: #fff;
}

.image-caption {
  font-size: 0.95em;
  color: var(--muted-text);
  margin-top: 0.6em;
}

/* =========================
   Callouts / Buttons (light unified)
========================= */
.note-box {
  background: var(--card-bg-color);
  border: 1px solid var(--border-color);
  border-left: 4px solid rgba(107, 114, 128, 0.55);
  padding: 12px 16px;
  margin: 20px 0;
  border-radius: var(--radius-sm);
  color: var(--text-color);
}

.course-code {
  color: #b91c1c;
  font-weight: 900;
}

.syllabus-link {
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.22);
  padding: 14px 18px;
  font-size: 1.05em;
  margin: 24px 0;
  text-align: center;
  border-radius: var(--radius-sm);
}

.syllabus-link a {
  text-decoration: none;
  color: #1d4ed8;
  font-weight: 900;
}

.syllabus-link a:hover { text-decoration: underline; }

/* Section highlight */
.highlight-section {
  background: #fff7ed;
  padding: 0.75em 1em;
  border-left: 5px solid #fb923c;
  color: #7c2d12;
  border-radius: var(--radius-sm);
  font-size: 1.1em;
  margin-top: 2em;
}

/* Big link button */
.env-link {
  background: var(--primary-color);
  color: #fff;
  text-decoration: none;
  padding: 0.55em 0.95em;
  border-radius: 999px;
  display: inline-block;
  transition: filter 0.2s;
}

.env-link:hover {
  filter: brightness(0.92);
  text-decoration: none;
}

/* =========================
   Responsive
========================= */
@media (max-width: 1024px) {
  .site-container {
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-areas:
      "header header"
      "sidebar-left main";
  }
  .sidebar-right { display: none; }
}

@media (max-width: 768px) {
  .site-container {
    display: block;
    padding: 0 1em 2em;
  }

  .site-header {
    position: sticky;
    top: 0;
    padding: 0.9rem 0;
  }

  .sidebar-left {
    position: static;
    padding-top: 1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
  }

  .sidebar-left ul {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 10px;
  }

  .sidebar-left li { flex-shrink: 0; }

  main {
    margin-top: 0;
    padding: 1.4rem 1.2rem;
    border-radius: 12px;
  }

  .header-links { font-size: 0.95rem; }
}

.sidebar-right li a.active-toc{
  background: var(--hover-bg-color);
  border-left-color: var(--primary-color);
}

/* ===== force unified background (last wins) ===== */
body{
  background-color: #f6f7fb;
  background-image:
    radial-gradient(1200px 600px at 15% -10%, rgba(37,99,235,0.12), transparent 60%),
    radial-gradient(1000px 520px at 95% 0%, rgba(37,99,235,0.07), transparent 55%);
  background-repeat: no-repeat;
  background-attachment: fixed; /* 長いページでも同じ見え方に */
}

/* コンテナが背景を塗ってしまう事故を防ぐ */
.site-container{
  background: transparent;
}
