* {
  box-sizing: border-box;
}
body {
  margin: 0;
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
  font-family: system-ui, sans-serif;
  background: #0d1117;
  color: #c9d1d9;
  transition: grid-template-columns 0.3s ease;
}

body.sidebar-closed {
  grid-template-columns: 40px 1fr;
}

#sidebar {
  background: #161b22;
  border-right: 1px solid #30363d;
  display: flex;
  flex-direction: column;
  position: relative;
}

#sidebar-toggle {
  background: none;
  border: none;
  color: #c9d1d9;
  font-size: 1.2rem;
  padding: 0.5rem;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}
body:not(.sidebar-closed) #sidebar-toggle {
  text-align: right;
}

#pattern-tabs {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
  padding: 0.5rem;
}
body.sidebar-closed #pattern-tabs {
  display: none;
}

#pattern-tabs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
}
#pattern-tabs button {
  white-space: nowrap;
  background: #21262d;
  color: #c9d1d9;
  border: none;
  border-radius: 8px;
  padding: 0.15rem 0.6rem;
  height: 2rem;
  line-height: 2rem;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
#pattern-tabs button:hover {
  background: #2d333b;
}
#pattern-tabs button.active {
  background: #3b82f6;
  color: #fff;
}

#main-content {
  overflow-y: auto;
  padding: 1rem;
}

.grid-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  justify-content: start;
}

@media (max-width: 768px) {
  body.sidebar-closed {
    grid-template-columns: 40px 1fr;
  }
  .grid-container {
    grid-template-columns: 1fr;
  }
}

.card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transform: translateY(-2px);
}
.card h2 {
  margin: 0;
  font-size: 1.1rem;
}
.card h2 a {
  color: #58a6ff;
  text-decoration: none;
}
.card h2 a:hover {
  text-decoration: underline;
}
.card pre {
  background: #0d1117;
  padding: 0.75rem;
  border-radius: 4px;
  overflow-x: auto;
}
.card code {
  font-family: "Source Code Pro", monospace;
  font-size: 0.9rem;
  color: #c9d1d9;
  white-space: pre;
  line-height: 1.4;
}
