* { box-sizing: border-box; padding: 0; margin: 0; }

html, body {
  background: #f8fafc;
  color: #0f172a;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 280px;
  min-width: 280px;
  height: 100vh;
  background: #1e293b;
  color: #e2e8f0;
  overflow-y: auto;
  border-right: 1px solid #334155;
  position: sticky;
  top: 0;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid #334155;
  background: #0f172a;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.125rem;
  font-weight: 700;
  color: #f1f5f9;
  text-decoration: none;
}
.logo:hover { color: #a78bfa; }

.mobile-close, .mobile-menu {
  display: none;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px 8px;
}

.nav { padding: 8px 0; }

.dir-wrapper { display: flex; flex-direction: column; }

.dir-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.dir-button:hover { background: #334155; color: #f1f5f9; }

.dir-icon {
  font-size: 0.75rem;
  width: 12px;
  color: #94a3b8;
  transition: transform 150ms;
}
.dir-icon.collapsed { transform: rotate(-90deg); }

.dir-children.collapsed { display: none; }

.file-link {
  display: block;
  padding: 6px 12px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.8125rem;
  transition: background 150ms, color 150ms;
  border-left: 2px solid transparent;
}
.file-link:hover { background: #334155; color: #f1f5f9; }
.file-link.active {
  background: #334155;
  color: #a78bfa;
  border-left-color: #a78bfa;
  font-weight: 600;
}

.main {
  flex: 1;
  padding: 32px 48px;
  max-width: calc(100vw - 280px);
  overflow-x: auto;
}

.content { max-width: 900px; }

.loading {
  text-align: center;
  padding: 40px 16px;
  color: #94a3b8;
  font-size: 0.875rem;
}

/* 마크다운 */
.prose { color: #1e293b; }
.prose h1 {
  font-size: 2.25rem;
  font-weight: 800;
  margin-bottom: 1rem;
  color: #0f172a;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.5rem;
}
.prose h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.375rem;
}
.prose h3 {
  font-size: 1.375rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}
.prose h4 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: #334155;
}
.prose p { margin: 0.75rem 0; }
.prose ul, .prose ol { margin: 0.75rem 0; padding-left: 1.5rem; }
.prose li { margin: 0.25rem 0; }
.prose a { color: #7c3aed; text-decoration: none; }
.prose a:hover { text-decoration: underline; }
.prose code {
  background: #f1f5f9;
  color: #be185d;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.875em;
  font-family: 'Fira Code', 'Courier New', monospace;
}
.prose pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.875rem;
  line-height: 1.5;
}
.prose pre code { background: transparent; color: inherit; padding: 0; font-size: inherit; }
.prose blockquote {
  border-left: 4px solid #a78bfa;
  padding-left: 1rem;
  color: #64748b;
  margin: 1rem 0;
  font-style: italic;
}
.prose table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.875rem; }
.prose table th, .prose table td {
  border: 1px solid #e2e8f0;
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.prose table th { background: #f1f5f9; font-weight: 600; }
.prose table tr:nth-child(even) { background: #f8fafc; }
.prose hr { border: 0; border-top: 1px solid #e2e8f0; margin: 2rem 0; }
.prose img { max-width: 100%; border-radius: 6px; }

/* 홈 카드 */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 24px;
}
.home-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  text-decoration: none;
  color: #0f172a;
  transition: border-color 150ms, transform 150ms, box-shadow 150ms;
  display: block;
}
.home-card:hover {
  border-color: #a78bfa;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  text-decoration: none;
}
.home-card-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #1e293b;
}
.home-card-desc {
  font-size: 0.875rem;
  color: #64748b;
}

.error {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 16px;
  border-radius: 8px;
  margin: 24px 0;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 300ms;
  }
  .sidebar.open { transform: translateX(0); }

  .main {
    padding: 16px;
    padding-top: 56px;
    max-width: 100vw;
  }

  .mobile-menu {
    display: block;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 50;
    background: #1e293b;
    color: white;
    border-radius: 6px;
    padding: 6px 12px;
  }

  .mobile-close { display: block; }

  .prose h1 { font-size: 1.75rem; }
  .prose h2 { font-size: 1.375rem; }
}
